i need an expert in c++
Western Oregon University Page 1 of 5
CS-161 Assignment #8
General Submit this lab using the Moodle system by the beginning of lab on the due date.
Use the Attach File tool to attach your .cpp files with your solution. Each program should be in a separate file - they MUST be named exactly as specified in each problem. Do not attach any other files.
Each code file should have the standard comment at the top (see Lab1 or 2).
Read information into all programs in the specified order. Do not ask for extra input. If a program says something like “ask the user for their name and the number of hours they worked” you MUST read in the name first, then the number of hours and not prompt for any other input.
Readability and maintainability of your code counts. Poor formatting, confusing variable names, unnecessarily complex code, etc… will all result in deductions to your score.
Concepts Upon completion of this lab the student will be able to use multidimensional arrays.
Assignment Instructions
WordSearch Filename : assign8.cpp (This is the file name you MUST use for the file you submit for this problem.) OR assign8.cpp, WordSearch.cpp, WordSearch.h (main in assign8 and helper functions in other files) A word search is a puzzle where you try to find words hidden in a large grid of characters like the one below. The hidden words below are: double, heap, int, main, program, stack, void
H B G Q W R G X X I
E Y U A S L J A W J
A X D V A B I N T H
P R O G R A M H A A
K L U O B M F J L W
P M B O M O M V T Q
J Z L V D N A Z H D
G Y E D V O I D F D
X L D M N M N O P A
S T A C K U V M J P Write a menu driven program to help build a word search. Your program should start with an empty character grid and allow the user to build a puzzle. It should have a menu with the following options: 1: Print key 2: Print puzzle 3: Add horizontal word 4: Add vertical word 5: Check horizontal fit 6: Space count 8: Quit (7 is reserved for the optional challenge).
You MUST use these menu options. Do not change the order. Do not worry about bad input. Hint: You can get your menu system working without worrying about the rest of the problem.
Western Oregon University Page 2 of 5
CS-161 Assignment #8
Your program should ask the user for a number representing an option, then perform that option. After performing any option (other than 8), the user should get to enter a new option. Below are descriptions of the options. Each menu item should be implemented as a separate function. It is fine to add other functions, but you must have at least one function per option. If you do not get a particular option working, just print out a message to that effect (“Sorry, option 3 is not available”) and allow the user to choose a new option. Option 1: Print out the current puzzle grid in a format like (blank squares are shown as _ here, you can just print spaces if you want or some other special character to indicate blanks):
H _ _ _ _ _ _ _ _ _
E _ _ _ _ _ _ _ _ _
A _ D _ _ _ I N T _
P R O G R A M _ _ _
_ _ U _ _ _ _ _ _ _
_ _ B _ _ _ M _ _ _
_ _ L _ _ _ A _ _ _
_ _ E _ V O I D _ _
_ _ _ _ _ _ N _ _ _
S T A C K _ _ _ _ _ Option 2: Print out the current puzzle grid, but fill empty spaces with random characters:
H B G Q W R G X X I
E Y U A S L J A W J
A X D V A B I N T H
P R O G R A M H A A
K L U O B M F J L W
P M B O M O M V T Q
J Z L V D N A Z H D
G Y E D V O I D F D
X L D M N M N O P A
S T A C K U V M J P Continues…
Do not actually modify the puzzle grid, just print out random chars instead of _’s
Note – your grid should start with all _’s. This is what a partially filled grid should look like.
Western Oregon University Page 3 of 5
CS-161 Assignment #8
Option 3: Ask the user for a starting row (1-10), column (1-10) and a word. If the word is too long to fit, print an error message and return to the main menu. Otherwise, place it in the grid going to the right starting from the indicated location. You do not have to worry about overlapping words, if the user tries to place one word on top of another, go ahead and add the word and assume they know what they are doing. Initial State:
H _ _ _ _ _ _ _ _ _
E _ _ _ _ _ _ _ _ _
A _ _ _ _ _ _ _ _ _
P _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ Sample input 1:
Enter row: 3
Enter col: 1
Enter word: ENUM
Result (should NOT be automatically printed):
H _ _ _ _ _ _ _ _ _
E _ _ _ _ _ _ _ _ _
E N U M _ _ _ _ _ _
P _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ Sample input 2:
Enter row: 1
Enter col: 5
Enter word: PARAMETER
Result: Print “Error, does not fit”
“assume the user knows what they are doing” is a bad idea in the real world
Western Oregon University Page 4 of 5
CS-161 Assignment #8
Option 4: Ask the user for a starting row (1-10), column (1-10) and a word. This should work just like placing a horizontal word, but should place it going down starting from the indicated location. Once again, if the word is too long to fit, just print an error message and return to the main menu. Also, do not worry about existing words, overwrite anything that is there. Option 5: Ask the user for a starting row (1-10), column (1-10) and a word. Verify if the given word can fit horizontally in the indicated location. To “fit” a word needs to physically fit and all the letters in the word need to not change existing words in the grid. Print either “Fits” or “Does not fit”. Do not actually place the word. Given this starting grid (colors to show areas):
H _ _ _ _ _ _ _ _ _
E _ _ _ _ _ _ _ _ _
A _ D _ _ _ I N T _
P R O G R A M _ _ _
_ _ U _ _ _ _ _ _ _
_ _ B _ _ _ M _ _ _
_ _ L _ _ _ A _ _ _
_ _ E _ V O I D _ _
_ _ _ _ _ _ N _ _ _
S T A C K _ _ _ _ _ Sample input 1 (Placing “MEMORY” in the green area. It overlaps “MAIN”, but so that the “M”s match):
Enter row: 6
Enter col: 5
Enter word: MEMORY
Result: Fits Sample input 2 (placing “MEMORY” in the orange area where it overlaps “MAIN” but letters do not match up):
Enter row: 9
Enter col: 5
Enter word: MEMORY
Result: Does not fit Option 6: Print out how many blank spaces there are in the current puzzle. Given the grid shown in Option 5, your program should print 70. Option 8: The program should end. Ideally, it should just exit normally by finishing main. But you can also use this line to kill the program: exit(0);
Western Oregon University Page 5 of 5
CS-161 Assignment #8
Optional challenge: Add an option 7. It should print out the size and location of the largest horizontal opening in each row. If there is a tie, print the first of the larges gaps. For the grid in option 5 you would print: Row Gap Size Start Col 1 9 2 2 9 2 3 3 4 4 3 8 5 7 4 6 3 4 (This ties with the gap at 7) 7 3 4 (Another tie) 8 2 1 (Another tie) 9 6 1 10 5 6
Debugging Tip: Although your grid in the final program should start out with all _ characters, it will probably make it easier to test your program if you start it with some data. Use something like this to initialize your 2D array while testing: { {"H","_","_","_","_","_","_","_","_","_"}, {"E","_","_","_","_","_","_","_","_","_"}, {"A","_","D","_","_","_","I","N","T","_"}, {"P","R","O","G","R","A","M","_","_","_"}, {"_","_","U","_","_","_","_","_","_","_"}, {"_","_","B","_","_","_","M","_","_","_"}, {"_","_","L","_","_","_","A","_","_","_"}, {"_","_","E","_","V","O","I","D","_","_"}, {"_","_","_","_","_","_","N","_","_","_"}, {"S","T","A","C","K","_","_","_","_","_"} }; Then when you are done, comment out or delete that code and replace it with something to initialize the grid to a totally empty one.