, , , , , ,

[SOLVED] Cmsc 202 project 3 – spy game

$25

File Name: Cmsc_202__project_3_–_spy_game.zip
File Size: 301.44 KB

Categories: , , , , , , Tags: , , , , , ,
5/5 - (1 vote)

1. Overview
In this project you will:
• Implement a linked-list data structure,
• Use dynamic memory allocation to create new objects,
• Practice using C++ class syntax,
• Practice implementing member functions,
• Practice object-oriented thinking.
2. Background
You have recently been hired as a member of a clandestine governmental agency tasked with intercepting and managing sets of clues. As you examine pages and pages of clues, you realize that there is a very definite pattern. A pattern that if you had enough time, you could find the true meaning of the data. If only you had enough time…
For this spy game, you will be intercepting the clues in the form of a file. Your responsibility will be to import the file and to examine it to see if you can figure out which clues are meaningful and which pieces are not. Because you aren’t sure exactly how long a message will be, you have decided to use the linked list as the data structure for your program.
For this assignment, you will be receiving parts of the clue in a completely random order. Each clue will have a number and a string. The clue will need to be evaluated to see if it is a real clue or a fake clue. After you assemble all of the real clues, a message will be displayed to you. You realize that the real clues are the clues where the number is a perfect square or perfect cube – everything else is junk.
After you figure out which clues are “real”, you will need to sort them based on either their roots.3. Assignment Description
Your assignment is to build an application that can read a file and decrypt its hidden message.
1. The file containing the message will contain one or more lines of data.
2. The data will be in the form of an integer and a string.
3. Each file will contain at least one message.
4. The file needs to be imported into a user made linked list.
5. The data imported into the linked list will either be “real” or “fake”.
6. If the int is a perfect square or perfect cube then it is “real”. All other clues are “fake” and should not be used.
7. After all of the “real” clues are identified, they need to be sorted by their roots. The message will be made up of both roots of the perfect squares and roots of the perfect cubes.
8. An easy to read message or phrase should display after the file is correctly decrypted.
9. All user inputs will be assumed to be the correct data type. For example, if you ask the user for an integer, they will provide an integer.
10. Regardless of the sample output below, all user input must be validated. If you ask for a file name and they enter a file name that doesn’t exist, it should notify the user. If you ask for a number between 1 and 5 with the user entering a 8, the user should be re-prompted.
11. Have a main menu that asks the user if they want to:
a. What would you like to do?:
i. Load a new encrypted message
ii. Display a raw message
iii. Display an encrypted message
iv. Exit
1. Upon exit, nothing is saved
4. Requirements:
Initially, you will have to use the following files LinkedList.h, proj3.h, proj3.cpp and a variety of test input for the project (secret1 – 4). You can copy the files from Prof. Dixon’s folder at:
/afs/umbc.edu/users/j/d/jdixon/pub/cs202/proj3
To copy it into your project folder, just navigate to your project 2 folder in your home folder and use the command:
cp /afs/umbc.edu/users/j/d/jdixon/pub/cs202/proj3/*.* .
Notice the trailing period is required (it says copy it into this folder).
• The project must be completed in C++. You may not use any libraries or data structures that we have not learned in class. Libraries we have learned include , , , , , , and . You should only use namespace std.
• As described in the LinkedList.h file, you will be implementing the linked list on your own. Do not use the STL for this project.
• You must use the function prototypes as outlined in the proj3.h header file. The proj3.h file includes additional comments describing what the function is expected to do. You may not edit the proj3.h file. Additionally, you will need to use the LinkedList.h as a template for your class definition files.
• You first need to write the functions for the class (LinkedList.cpp) based on the header file (LinkedList.h). The Nodes for the linked list that you are implementing are structs that hold two pieces of information – an int and a string. One other important piece is that the only clues that are real are where the int is a perfect square or perfect cube. You will need to implement the function to check for that!
• Next you need to code up the various functions that are called in the proj3.cpp file that are prototyped in proj3.h.
o mainMenu() – Provided in the proj3.cpp file.
o main() – Provided in the proj3.cpp file.
o readFile() – Asks the user for a file name. Opens file and tried to read contents into a singly linked list. File contains unknown number of lines. Each line has an int and a string. If a file has already been loaded, asks the user if they would like to append (add to bottom) the current message, overwrite (clear existing linked list) the current message, or cancel. More than one file can be loaded for display because secret messages can be sent separately.
o displayMessage() – If an encrypted message has been loaded displays the “raw” message. It calls the display method of the linked list then calls the sort method of the linked list and then displays the linked list again. If not, notifies the user that a message has not been loaded.
o exitLinked() – Exits the application with a message, “Have a nice day!”
o displayEncrypt() – If an encrypted message has been loaded, the decrypt method of the linked list is called and the output of the method returns a new linked list called list2. The list2 linked list is sorted and then displayed.
5. Sample Input and Output
5.1. Sample Run
A normal run of the compiled code would look like this with user input highlighted in blue:
-bash-4.1$ ./proj3
What would you like to do?:
1. Load a new encrypted message
2. Display a raw message
3. Display an encrypted message
4. Exit
1
What is the file name?:
secret1.txt
New message loaded
What would you like to do?:
1. Load a new encrypted message
2. Display a raw message
3. Display an encrypted message
4. Exit
2
Payload of list are:
the->is->test->very->this->first->END
Payload of list are:
very->is->first->this->the->test->END
What would you like to do?:
1. Load a new encrypted message
2. Display a raw message
3. Display an encrypted message
4. Exit
3
Payload of list are:
this->is->the->first->test->END
What would you like to do?:
1. Load a new encrypted message
2. Display a raw message
3. Display an encrypted message
4. Exit
4
Have a nice day!
-bash-4.1$
Some additional validation would look like this:
-bash-4.1$ ./proj3
What would you like to do?:
1. Load a new encrypted message
2. Display a raw message
3. Display an encrypted message
4. Exit
5
What would you like to do?:
1. Load a new encrypted message
2. Display a raw message
3. Display an encrypted message
4. Exit
0
What would you like to do?:
1. Load a new encrypted message
2. Display a raw message
3. Display an encrypted message
4. Exit
2
You haven’t loaded an encrypted message yet.
What would you like to do?:
1. Load a new encrypted message
2. Display a raw message
3. Display an encrypted message
4. Exit
3
You haven’t loaded an encrypted message yet.
What would you like to do?:
1. Load a new encrypted message
2. Display a raw message
3. Display an encrypted message
4. Exit
Finally this is if you are going to try to load 2 or more files:
-bash-4.1$ ./proj3
What would you like to do?:
1. Load a new encrypted message
2. Display a raw message
3. Display an encrypted message
4. Exit
1
What is the file name?:
secret1.txt
New message loaded
What would you like to do?:
1. Load a new encrypted message
2. Display a raw message
3. Display an encrypted message
4. Exit
1
Do you want to:
1. Overwrite the message
2. Append the message
3. Cancel
1
Previous message cleared
What is the file name?:
test2.txt
Message load failed
What would you like to do?:
1. Load a new encrypted message
2. Display a raw message
3. Display an encrypted message
4. Exit
6. Output
6.1. Secret1.txt Run
There are many sample input files for this project. The first input file is called secret1.txt and looks like this:
2197 the
121 is
6859 test
20 very
343 this
256 first
The “raw” message would look like this:
Payload of list are:
the->is->test->very->this->first->END
Payload of list are:
very->is->first->this->the->test->END
The “decrypted” message would look like this:
Payload of list are:
this->is->the->first->test->END
6.1. Secret2.txt Run
There are many sample input files for this project. The second input file is called secret2.txt and looks like this:
8925 the
25921 are
234232 give
324210 assignment
883 why
222551 protection
65441 an
14172488 goose
6991691 ardent
11764092 awesomeness
17516287 cozy
17993003 humility
15349498 sweetheart
837 prominence
13225 you
As this is a long file, this is only part of it. The “decrypted” message would look like this:
Payload of list are:
you->are->a->silly->goose->END
There are two additional scenarios you can run. The first is secret3.txt and it is very long (~10,000 lines). It has one response with an output message that is around 14 words long (not including the END).
Finally, there is a secret_pt1.txt and secret_pt2.txt. This is designed so you can practice “appending” two files. When you put the two files together, you make one meaningful message. It is 12 words before the END.
7. Compiling and Running
Because we are using a significant amount of dynamic memory for this project, you are required to manage any memory leaks that might be created. For a linked list, this is most commonly related to the dynamically allocated nodes. Remember, in general, for each item that is dynamically created, it should be deleted using a destructor.
One way to test to make sure that you have successfully removed any of the memory leaks is to use the valgrind command.
Since this project makes extensive use of dynamic memory, it is important that you test your program for memory leaks using valgrind:
valgrind ./proj3
If you have no memory leaks, you should see output like the following:
==14746==
==14746== HEAP SUMMARY:
==14746== in use at exit: 0 bytes in 0 blocks
==14746== total heap usage: 42 allocs, 42 frees, 931 bytes allocated
==14746==
==14746== All heap blocks were freed — no leaks are possible
==14746==
==14746== For counts of detected and suppressed errors, rerun with: -v
==14746== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)
The important part is “in use at exit: 0 bytes 0 blocks,” which tells me all the dynamic memory was deleted before the program exited. If you see anything other than “0 bytes 0 blocks” there is probably an error in one of your destructors. We will evaluate this as part of the grading for this project.
Additional information on valgrind can be found here: http://valgrind.org/docs/manual/quick-start.htmlBased on our practice this semester, you need to write your own makefile to compile and run your code. Your final output file should be proj3.
Once you have compiled using your makefile, enter the command ./proj3 to run your program. If your executable is not proj3, you will lose points. It should look like the sample output provided above.
8. Completing your Project
When you have completed your project, you can copy it into the submission folder. You can copy your files into the submission folder as many times as you like (before the due date). We will only grade what is in your submission folder.
For this project, you should submit these files to the proj3 subdirectory:
proj3.h — should be unchanged except if you choose to add additional constants.
proj3.cpp — should include your implementations of the required functions.
LinkedList.cpp – should include your implementations of the class functions
As you should have already set up your symbolic link for this class, you can just copy your files listed above to the submission folder
b. cd to your project 3 folder. An example might be cd ~/202/projects/proj3
c. cp proj3.cpp proj3.h LinkedList.cpp ~/cs202proj/proj3
You can check to make sure that your files were successfully copied over to the submission directory by entering the command
ls ~/cs202proj/proj3
You can check that your program compiles and runs in the proj3 directory, but please clean up any .o and executable files. Again, do not develop your code in this directory and you should not have the only copy of your program here.
For additional information about project submissions, there is a more complete document available in Blackboard under “Course Materials” and “Project Submission.”
IMPORTANT: If you want to submit the project late (after the due date), you will need to copy your files to the appropriate late folder. If you can no longer copy the files into the proj3 folder, it is because the due date has passed. You should be able to see your proj3 files but you can no longer edit or copy the files in to your proj3 folder. (They will be read only)
• If it is 0-24 hours late, copy your files to ~/cs202proj/proj3-late1
• If it is 24-48 hours late, copy your files to ~/cs202proj/proj3-late2
• If it is after 48 hours late, it is too late to be submitted.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Cmsc 202 project 3 – spy game
$25