University of Arkansas



CSCE 2004 - Homework 5Due Date – Thursday April 2, 11:59pmThis assignment must be done individually1. Overview For this assignment, you will create a board game called “Pay Day”. The program provides an interface through which two players can play against each other. The objective of the game is to earn more money than your opponent. When the game begins, a board will be printed with random letters in it. Each letter is associated with a specific event that occurs when a player lands on that spot. At the beginning of each turn the player will decide whether or not they wish to roll the dice or pass their turn by typing ‘r’ or ‘p’ respectively. If they choose to roll the dice, then the player advances the number of spaces indicated on the die. The player moves left to right and top to bottom through the board. When they hit the end of a row, they advance to the first spot on the next row and then keep counting until they move over the appropriate number of spots. When a player lands on a spot, a message will be displayed describing what event happened and how their money was affected. The game ends when a player advances past the last spot on the board. The final money for each player is displayed along with the name of winner (e.g., "Player One" or "Player Two").There is a completed solution that you can run if you log in to turing. From the terminal's command line type: ssh turing.csce.uark.edu If your username in your VM is different than you UofA id, type ssh myusername@turing.csce.uark.edu Login to turing (the CSCE linux server) by providing your UofA password then type: prompt$ ~sgauch/public_html/2004/S15/hw/hw5soln 2. Design: For this assignment you are given most of a printBoard function which displays the board, a rollDice function that returns a value between 1 and 6, and a 2-D character array. You must first decide how you wish to design your board. It must be a 4 x 6 board, but it can be filled with whatever “events” you decide will occur. Fill in all of the spots on the board. For 10 bonus points you may decide to randomize the board instead of hard-coding how it is setup. You should create a randomBoard function if you choose to do this. Here are sample pictures of a filled board and what it looks like after a player rolls. In this example, B indicates they have to pay a bill, C indicates a car wreck, G indicates grandma gave you money, L indicates you won the lottery, F indicates feeding the dog, P indicates it’s payday. The 1 indicates the position of player 1 and the 2 indicates the position of Player 2. In the first board, neither player is present and by the third board, both players show up because they have made a mover.The other following functions MUST be implemented:welcomeMessage - Displays a message to the user explaining what the game does and how to playinitBoard - initializes the board with events (hard coded or randomly (bonus))playTurn - Controls the logic for a player’s turn and moving across the board. This will call multiple other functions (e.g., diceRoll and handleEvent)handleEvent - Changes a player’s money when an event occurs and displays a message of what happeneddisplayWinner – Displays a message which tells the final score and who the winner wasAfter a player rolls, their player number (1 or 2) should appear in the game board. If player 1 and 2 land on the same spot, display a 3 at that position on the board. You may choose the return types on all of your functions except printBoard and rollDice. When the player reaches the end of the 4th row the game is over, the money totals are displayed and the winner is announced.3. Implementation: Begin by creating welcomeMessage to greet the user. Then you can move on initializing the board and displaying it. Add, one step at a time, a loop controlling whose turn it is. Each time through the loop, you should play one turn where a turn consists of rolling the dice, moving the player, updating the player's money based on the event at their new locations, correctly displaying the location of the player. Once a player wins, the game should end your program should display the final money total's and which player won.4. Testing: Test your program to check that it operates correctly for all of the requirements listed above. The only error checking from the user is for the input to roll or pass. Make sure that the player moves across the board correctly and events are resolved as you would expect them to. The game ends when one player travels across the entire board.You can collect the output in a file using a linux utility called script. Script captures everything that appears on the screen to a file. You should capture your program compiling without errors and then a couple test runs of your program with correct and incorrect inputs. When you are done, type exit. This creates a file called typescript that you should include in your report. prompt$ scriptprompt$ g++ -Wall hw5.cpp -o hw5prompt$ ./hw5 (one test) prompt$ ./hw5 (another test) prompt$ ./hw5 (another test) prompt$ exit prompt$ exitprompt$ mv typescript MYID.typescript.txt (rename file before submission) 5. Documentation: When you have completed your C++ program, write a short report using the project report template describing what the objectives were, what you did, and the status of the program. Describe the test cases you included in your typescript. Does it work properly for all test cases? Are there any known problems? Save this report to be submitted electronically. There is a report template on the class web site which you should use.Include the typescript file captured during testing as an appendix at the end of the document. 6. Project Submission: In this class, we will be using electronic project submission to make sure that all students hand their programming projects and labs on time, and to perform automatic analysis of all programs that are submitted. Rename your program and documentation files and typescript: 123456789.hw5.cpp123456789.hw5.docx or .doc or .pdf or .txt 123456789.hw5.typescript.txt using your UAID number in place of 123456789. Use the Blackboard site for this class to submit these three files (or you can include the typescript as an appendix within your report). The dates on your electronic submission will be used to verify that you met the due date above. All late projects will receive reduced credit: 10% off if less than 1 day late, 20% off if less than 2 days late, 30% off if less than 3 days late, ? no credit if more than 3 days late. You will receive partial credit for all programs that compile even if they do not meet all program requirements, so handing projects in on time is highly recommended. If your program does not compile, the correctness section of the project score will be a 0. This leaves 50 possible points for the project design, implementation, testing and report. 7. Academic Honesty Statement: · Students are expected to submit their own work on all programming projects, unless group projects have been explicitly assigned.· Students are NOT allowed to distribute code to each other, or copy code from another individual or website. · Students ARE allowed to use any materials on the class website, or in the textbook, or ask the instructor and/or GTAs for assistance. This course will be using highly effective program comparison software to calculate the similarity of all programs to each other. Please do not be tempted to plagiarize from another student. Violations of the policies above will be reported to the Provost's office and will result in a ZERO on the programming project, an F in the class, or suspension from the university, depending on the severity of the violation and any history of prior violations. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download