Prog 6: Across Undo
This program is the same as the previous one, except we always use the small dictionary and allow undoing moves. Attempting to undo a move at the beginning of the game gives a warning message and allows the user to retry. Running the program looks something like the following:
Author: Dale Reed Program: #6, AcrossWords with Undo TA: Claude Shannon, Th 4-5 Mar 30, 2017 Welcome to AcrossWord puzzle, where you rotate rows or columns to restore the board back to containing four words. Each move is a row or column letter followed by the rotation distance 1,2 or 3. When prompted to provide input you may enter: Enter 'r' to reset the board to user-defined values. Enter 'u' to undo a move. Enter 'o' for original board to be shown Enter 'x' to exit the program. There are 500 4-letter words. E F G H ------- A| t i l m B| f h o s C| l t e a D| s e l t List: 1 1. Enter the row or column to be rotated, and a number 1..3: o You chose 'o' for the original board to be shown. Here are the underlying words: E F G H ------- A| t i l l B| h o s t C| t e a m D| s e l f E F G H ------- A| t i l m B| f h o s C| l t e a D| s e l t 1. Enter the row or column to be rotated, and a number 1..3: d1 E F G H ------- A| t i l m B| f h o s C| l t e a D| t s e l List: 2->1 2. Enter the row or column to be rotated, and a number 1..3: h1 E F G H ------- A| t i l l B| f h o m C| l t e s D| t s e a List: 3->2->1 3. Enter the row or column to be rotated, and a number 1..3: u You chose 'u' to undo the most recent move. * Undoing move * E F G H ------- A| t i l m B| f h o s C| l t e a D| t s e l List: 2->1 2. Enter the row or column to be rotated, and a number 1..3: u You chose 'u' to undo the most recent move. * Undoing move * E F G H ------- A| t i l m B| f h o s C| l t e a D| s e l t List: 1 1. Enter the row or column to be rotated, and a number 1..3: u You chose 'u' to undo the most recent move. *** You cannot undo past the beginning of the game. Please retry. E F G H ------- A| t i l m B| f h o s C| l t e a D| s e l t List: 1 1. Enter the row or column to be rotated, and a number 1..3: c3 E F G H ------- A| t i l m B| f h o s C| t e a l D| s e l t List: 2->1 2. Enter the row or column to be rotated, and a number 1..3: h2 E F G H ------- A| t i l l B| f h o t C| t e a m D| s e l s List: 3->2->1 3. Enter the row or column to be rotated, and a number 1..3: u You chose 'u' to undo the most recent move. * Undoing move * E F G H ------- A| t i l m B| f h o s C| t e a l D| s e l t List: 2->1 2. Enter the row or column to be rotated, and a number 1..3: u You chose 'u' to undo the most recent move. * Undoing move * E F G H ------- A| t i l m B| f h o s C| l t e a D| s e l t List: 1 1. Enter the row or column to be rotated, and a number 1..3: o You chose 'o' for the original board to be shown. Here are the underlying words: E F G H ------- A| t i l l B| h o s t C| t e a m D| s e l f E F G H ------- A| t i l m B| f h o s C| l t e a D| s e l t 1. Enter the row or column to be rotated, and a number 1..3: b3 E F G H ------- A| t i l m B| h o s f C| l t e a D| s e l t List: 2->1 2. Enter the row or column to be rotated, and a number 1..3: c3 E F G H ------- A| t i l m B| h o s f C| t e a l D| s e l t List: 3->2->1 3. Enter the row or column to be rotated, and a number 1..3: h2 E F G H ------- A| t i l l B| h o s t C| t e a m D| s e l f List: 4->3->2->1 Congratulations! You solved it!
Notes:
Note that you have less than two weeks for this program after the deadline for the previous program. No late submissions are accepted for this last program.
You will need to create a struct to hold the board, moveNumber and pointer to the next Node. I suggest you look at previous semester solutions to the last program to give you ideas on this.
This version of the program will only use the small dictionary and will not give the choice of some other dictionary.
Steps to Take:
Create the struct at the top of your program
Within main create the list pointer, initialized to NULL
After the starting board position is created, and the moveNumber is set to 1, create the first node and put it on the list. This will function as a sentinel node for us, and should never be taken off the list, so your list should always have at least this single node on it.
After each move is made and the move number is incremented, prepend a new node onto the list with the current board and move number information.
Besides displaying the board after each move, also display all the move numbers on the linked list. This will help you with debugging.
If the user enters 'u' to undo a move you should remove the node at the front of the list (the most recent node with the current board and move number on it). Then restore the board and move number from the current front of the list, which should correspond to the previous move.
Submitting your Program
Your program must have the .cpp file extension. The name of the program you will turn in should be prog6Undo followed by your netid and the .cpp file extension. In other words, if your netid is reed then your program would be called: prog6Undoreed.cpp Remember, you may not work with a partner on this program!
You must also zip up the file you turn in, which typically is done by right-clicking on it and choosing the "compress" option. After zipping your program (e.g. prog6Undoreed.cpp), you will likely end up with a file called something like:
prog6Undoreed.zip
Only turn in this single file, turning it in on Blackboard into the assignment Program 6. Do not turn in any dictionary files. Please do not put it into a folder before zipping it, rather zip the one file by itself.
After submitting your program to Blackboard, select it to download it from Blackboard so you can verify that you uploaded the correct file. You will not receive credit for this program if you submit the wrong file!
Failing to follow these naming conventions and failure to turn in a zip file will result in a 5 point deduction, even if everything else is perfect in your program.