ASSIGNMENT 7
In this assignment, you are going to implement a cheating program for word puzzles. The user will enter the word to be searched, and your program will determine where it starts in the puzzles.
Assume that you have a 12x15 puzzle. The contents of the puzzle should be the same with the one in the following example (Figure 1).
0 1 2 3 4 5 6 7 8 9 10 11
|
Another trivial task is to implement a function which computes the length of a given string, since you are not allowed to use built-in string functions such as strlen.
The main challenge of this assignment is to implement the function which actually searches the string in the puzzle. Note that the word may be written in the puzzle from left to right, right to left, top to bottom and eventually bottom to top.
● Function 1 (15 pts):
Name of the function: printPuzzle
○ Return type of the function: void
Parameter: a character matrix
In this function, you will print the word puzzle which is the content of the character matrix as in the example Assume that the word puzzle will be 12x15 character matrix.
● Function 2 (15 pts):
Name of the function: computeLength
○ Return type of the function: int
Parameter: a string
In this function you will compute and return the length of the input Note that, you are not allowed to use built-in string functions such as strlen.
● Function 3 (40 pts):
Name of the function: findString
○ Return type of the function: int
Parameter: a character matrix
Parameter: a string
Parameter: an integer value (length of the string in 2nd parameter)
In this function, you will search the string in the character matrix. If found, the function returns the index of the starting point of the string in the character If not found, the function returns -1.
Index values of character matrix are as follows:
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
Figure 3: Puzzle Indexes
● Main function:
In the main function, you will take the puzzle from the user line by line where each line is a string with 12 letters. (15 pts)
Then, you will print the puzzle on the screen by calling printPuzzle
Finally, you will ask the string to be searched from the user continuously. If the user enters ‘q’ or ‘Q’, terminate the program, otherwise find the starting position of the string in the puzzle by calling findString function and print it on the (15 pts)
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of