Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Your first assignment is to write a program to play the following game, described in exercise 5 in Section 1.13.3, which the user plays against
Your first assignment is to write a program to play the following game, described in exercise 5 in Section 1.13.3, which the user plays against the computer. Hint: I suggest that you also do Problem 2 in Section 1.13.3 before attempting this problem (P.51). Do not submit Problem 2, however. You will also need the suggestion at the beginning of Problem 3 and, perhaps, some ideas from that problem description. Exercise 5. Write a program to play the following game, which the user plays against the computer. This game is played on an imaginary game board that has numbered spaces arranged in a circle. [11] For example, here is what a game board with 12 spaces might look like. - When the program starts, the user is asked to specify how many spaces there are on the game board. There must be at least five spaces. - The computer then randomly selects two spaces (excluding space numbers 0 and 1): One of the selected spaces is The Goal. The other is The Pit. - The computer announces the two special spaces. - Play then starts from space \#0: Each player, in turn, "rolls" a pair of dice and "moves" to another space by advancing N spaces (where N is the number that came up on the dice). For example, using the sample game board with 12 spaces, if the user rolled a 10 ( 6 plus 4) on her first turn and a 7(3+4) on her second turn, then she would land on space \#5. That's where she would start on her next turn. - The user and the computer take turns rolling the dice and moving around the board. Each move is displayed on the screen (as text, not graphics; e.g., "You are now on space #3). - The game continues until one player lands on The Goal (and wins the game) or on The Pit (and loses the game). - The computer announces the outcome of each game and keeps track of each player's wins and losses. - The user can choose single play (user must press for each roll of the dice) or continuous play (dice are automatically rolled and play continues until someone wins). - After each game the user can choose to quit or play another game. For this assignment you are to follow the procedure outlined below. Please read these instructions carefully. 1. Create a directory named hw01 that contains all of the source code for your program and nothing else. 2. Design, code, compile, and thoroughly test your program. 3. Make sure that your program files each begin with a substantial comment section that includes: - your name - program name - a brief description of the contents of the file - the date of your last modification to the file 4. Make sure that your program does not contain any lines that are longer than 79 characters. 5. Prepare and submit a script file similar to the following: 6. script hw01script // open the script file 7. cat prog1file1 // list the file(s) for your program 8. cat prog1file2... (etc.) // into the script. (see note below) 9. cat Makefile // If you wrote a makefile list it. 10. make // build your program 11. /hw01 // give a good demo of the program 12. exit // close the script file 13. make distclean [Note: In general, if you have pairs of files such as: thing.h and thing.cpp ALWAYS list the .h file first and then the .cpp file.] 14. Prepare a gzipped tarball that contains all of your source code files and data files so that I can easily build and run your program. The command to do this is: tar -czf yourname-hw1.tar.gz hw01/ This command will create a compressed archive containing all files in the directory as well as any subdirectories, so make sure that you delete all backup files and binary files that may have been produced while you were editing and debugging your program before creating this tarball. Make sure that your tarball contains your script file. 15. Finally: Mail your tarball as an attachment to: suffolk.edu Make sure that you have a Subject: line that says: CMPSC331
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started