首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
C++留学生程序讲解、辅导program程序、讲解c++编程语言 辅导留学生 Statistics统计、回归、迭代|讲解留学生Processing
项目预算:
开发周期:
发布时间:
要求地区:
Imperative
Programming in C
Assignment: Word Search
Introduction
A Word Search Puzzle consists of a grid of letters, with words hidden inside horizontally,
vertically and diagonally. The player’s task is to find all the words hidden in the grid.
Your task for this assignment is to create a Word Search Puzzle generator, and a program that
lets someone play the game against the clock.
An example Word Search Puzzle can be seen below.
In our version, we will ask the user to pick a category from a list, create a word search puzzle
based on that category and then let them type words they can see in the grid. If they find all
words before a timer reaches zero, they have won!
Specification
Your program should have the following features (30 marks in total):
1. Word Search Generation
a) Store a list of words on specific subjects (animals, colors, planets etc.) (2 marks)
b) Generate a 2D grid of letters, containing at least 6 words from a category found in
(1a). The size of the 2D grid should be definable (minimum 12x12).
o The words should be randomly placed within the grid
i. Horizontally (40% of the time) (2 marks)
ii. Vertically (40% of the time) (2 marks)
iii. Diagonally (20% of the time) (4 marks)
Diagonal words can be ascending or descending.
c) Ensure words do not overwrite one another. (5 marks)
2. Word Search Game
a) Welcome user to the program. (1 mark)
b) Present the user with a choice of categories from (1a). (1 mark)
c) Ask user to type in words that they can see in the grid ( 2 marks)
d) Highlight or remove correctly guessed words from the grid (4 marks)
e) Show message to user if time limit is reached, or all words found (2 marks)
For (2e). You do not need to end the game exactly when timer reaches 0, only when
user types in a word after timer has reached 0.
Coding
Programming Proficiency (3 marks)
Commenting / Formatting (2 marks)
Programming proficiency refers to how well your program runs, how it looks etc. Marks are
awarded for impressing the assessor here.
Commenting / Formatting marks are awarded for clear documentation of your code through
appropriate comments, correct indentation etc.
Implementation Guide
While you are free to code your program any way you want, it is recommended you follow
this implementation guide especially if you are unsure what order to develop your program.
Stage 1 – Grid Initialisation
The appendix contains a shell of a program that you can use as a starting point for this
assignment. The code will create a 2D character array and fill it with ‘x’ characters.
The first stage for your assignment should be to initialise a 2D array containing a random grid
of letters from the alphabet, and print the grid with appropriate formatting.
By the end of this stage your program should generate output similar to the following:
Example function prototypes for this stage are:
char **create2DArray(); //creates a 2D array of characters, returns pointer to array
void printArray(char** array); //prints out a 2D array on screen
Stage 2 – Inserting Words Horizontally
To make debugging easier you should initialise your grid to a common character for now. In
the following examples, the grid is filled with ‘.’ characters rather than random letters.
Extend your program so that it can insert horizontal words into the grid at random positions.
The recommended function prototype is:
void insertHorizontally(char* word, char** array);
Eventually you will need to test that you are not overwriting words already inserted into the
grid. However for the time being do not worry about testing for this.
Hints
Look at previous labs, lectures and code snippets for examples of how to insert
information into a 2D array
Use a for-loop to insert the word into the array one character at a time
You can use strlen() to get the length of a string.
When inserting a word into the array, you will need to make sure that there is enough
horizontal space for all the letters.
When you’ve finished this stage, your program should be able to pick from an array of words
and place them at random horizontal positions in the array, similar to the following
screenshot:
Stage 3 – Inserting Words Vertically/Diagonally
The next stage is to extend your program so that it can display words vertically and diagonally.
These are example function prototypes for this stage:
void insertVertically(char* word, char** array);
void insertDiagonally(char* word, char** array);
Remember that diagonal words can be ascending or descending. For example
Test your program by inserting a mixture of horizontal, vertical and diagonal words into the
grid. They should appear 40%, 40% and 20% of the time respectively.
You might have noticed that some words overlap in the example screenshots so far
(Chimpbear, Lhamadile). This is because we are not doing any testing to check if we are
replacing characters that were previously placed in the grid. It is up to you if you want to work
on this part first (Stage 5), or create the game first (Stage 4).
Stage 4 – Playing the game
We are now at a stage where we can program a game using the grid and associated words.
As the specification indicates, your program should work like this:
Welcome user to the program
Ask the user which category of words they would like
Generate a grid using words from this category
Start a timer (e.g. 2 minutes)
In a loop
o Present the grid to the user
o Allow the user to type in words they see in the grid
o If they find all words in time – print congratulations message
o If the timer reaches zero – print game over message
o (Optional) Clear screen after every guess
Exit
You are free to embellish your program however you like, but you must ensure that it can
perform at least the tasks above. If in doubt refer to the specification.
An example output of the game can be seen in the appendix.
Stage 5 – Overlapping words
You are on your own with this part of the assignment. You will need to ensure that when your
program generates words to place in the grid that they do not overlap words that were
previously inserted.
There are many ways to complete this stage. One potential solution is to use another 2D array
which tracks where words have previously been inserted (0=clear, 1=occupied). This could
then act like a mask when inserting new words. This would also require changing the insertion
function prototypes e.g.
insertHorizontally(animals[i], myArray, myMask);
An example mask can be seen below.
However as previously mentioned, using a simple mask is just one potential solution to this
stage.
General Hints
In Windows you can clear the screen using the code system("cls"); Similar functionality
will exist in OSX and Linux.
Lab 3 Exercise 5 contains an example of how to set text and background colour in
Windows. Similar functionality will exist in OSX and Linux.
The code sleep(2); found in
will cause your program to pause for 2 seconds.
You can use this function to manage the flow of your game.
When seeding the random number generator using srand(), if you give it a specific
number e.g. srand(5), your program will always generate the same puzzle. This can be
very useful when testing your program.
You can use strlen() to get the length of a string (found in
)
strlen() is useful for several tasks in the assignment, such as fitting strings inside the
grid, and iterating over each character in a string
To setup a countdown timer you will need to research
. Example code can
also be found in the appendix.
The Beep(x,y) function takes in a frequency and duration, and makes the speaker on
the PC speaker beep! For example Beep(1000,1000) will beep at 1Khz for 1 second.
You can use this to signify correct/incorrect messages, or even play a theme tune.
Windows only.
Submission
Use Blackboard to submit your source code. For this assignment you should zip your project
folder and submit the zip file. Ensure that all your program code is submitted to us. You will
also need to attend a lab session to get your work assessed before the end of week 12.
Ensure that the source code:
Contains a program header
Contains an appropriate level of comments
Follows a consistent style of indentation
Follows the usual C programming conventions
The deadline for submission will be published on Blackboard. Late submissions will be
penalised in line with School policy.
When submitting work it is your responsibility to ensure that all work submitted is
Consistent with stated requirements
Entirely your own work
Submitted through Blackboard on time
Please note that there are severe penalties for submitting work which is not your own. If
you have used code which you have found on the Internet or from any other source then you
must signal that fact with appropriate program comments and to the assessor.
Appendix A
Appendix B
Create a 2D Array
char **create2DArray(); //function prototype
#define WIDTH 16
#define HEIGHT 16
char** myArray; //global array
void main()
{
myArray = create2DArray();
}
//Creates a 2D array of WIDTH * HEIGHT and returns a pointer to it
char **create2DArray(){
int i,j;
char **array = (char **) malloc(sizeof(char *) * WIDTH);
for(i=0; i
array[i] = (char *) malloc(sizeof(char) * HEIGHT);
for(i=0; i
for(j=0; j
// array[i][j] = 65 + rand() % 25;
array[i][j] = 'x';
return array;
}
Stopwatch
#include
clock_t start = clock();
/*Do something*/
clock_t end = clock();
float seconds = (float)(end - start) / CLOCKS_PER_SEC;
Sleep
#include
printf( "I'll be back in 10 seconds...\n\n" );
sleep(10);
printf( "I'm back!" );
getchar();
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代写dts207tc、sql编程语言代做
2024-12-25
cs209a代做、java程序设计代写
2024-12-25
cs305程序代做、代写python程序...
2024-12-25
代写csc1001、代做python设计程...
2024-12-24
代写practice test preparatio...
2024-12-24
代写bre2031 – environmental...
2024-12-24
代写ece5550: applied kalman ...
2024-12-24
代做conmgnt 7049 – measurem...
2024-12-24
代写ece3700j introduction to...
2024-12-24
代做adad9311 designing the e...
2024-12-24
代做comp5618 - applied cyber...
2024-12-24
代做ece5550: applied kalman ...
2024-12-24
代做cp1402 assignment - netw...
2024-12-24
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!