Home | |
Schedule | |
Assignments | |
Lectures | |
Resources
Project Two Specifications
Introduction. This project focuses on conditional statements (if...else; switch) in the context of simulating a single play of the children's game, Rock, Scissors, Paper. Background. In the wild, this is a two-person game played as follows. The two adversaries stand facing each other. At an agreed-upon moment each throws forward a single hand/fist signaling one of the three options: Rock (a clenched fist), Scissors (index and middle finger extended, the others folded under the palm), Paper (all fingers extended straight out). If the two options signaled are the same, a tie is declared. If Rock is shown by one adversary and Scissors by the other, Rock wins (Rock smashes Scissors). If Scissors and Paper are shown, Scissors wins (Scissors cut Paper). If Paper and Rock are shown, Paper wins (Paper covers Rock).
In our simulation, we will input the player's throws from a file, and we announce who wins. The player's options will be read as 'R' or 'r' (for Rock), 'S' or 's' (for Scissors), or 'P' or 'p' (for Paper).
The specifications:
The output: The output file (which must be named proj2.out) must contain two non-blank lines of output for a single play of the game. There must be a row of dashes and a blank line at the beginning and end of the file.
If the input file reads "RS", the output file must appear as follows: -------------------------------------------------------------- Player 1 plays Rock and Player 2 plays Scissors. Player 1 wins! Rock smashes Scissors. -------------------------------------------------------------- If the input file reads "RP", the output must appear as follows: -------------------------------------------------------------- Player 1 plays Rock and Player 2 plays Paper. Player 2 wins! Paper covers Rock. -------------------------------------------------------------- If the input file reads "sS", the output must appear as follows: -------------------------------------------------------------- Player 1 plays Scissors and Player 2 plays Scissors. It's a tie! Neither wins; neither loses. -------------------------------------------------------------- If the input file reads "sp", the output file must read as follows: -------------------------------------------------------------- Player 1 plays Scissors and Player 2 plays Paper. Player 1 wins! Scissors cuts Paper. -------------------------------------------------------------- Program testing: The directory ~csci131/PROJECTS/PROJ2 contains, among other things, files named test2, proj2a.dat, proj2b.dat, proj2c.dat, proj2d.dat, model2.out and model_monitor2.out. Copy these files into a directory which also contains your proj2.cc. First test your code by making your own data file, named proj2.dat. You can make the file yourself by opening a file in emacs and typing two characters (e.g. rs) at the very beginning of the file. Make sure you don't put any spaces or blank lines before the characters! You can look at proj2a.dat for an example. If you prefer, you can copy one of the data files copied from the csci131 directory:
You can then run your program by typing:
You can view the output of the program by typing:
or by opening proj2.out in an emacs window. Change the characters in proj2.dat to test a variety of possible inputs. Once you are convinced your program works as it should, you can test it by typing ./test2. The test2 script will compile your program and run it five times, once using proj2a.dat once using proj2b.dat, once using proj2c.dat, once using proj2d.dat and finally after deleting the proj2.dat file and running it with no input file available. When you run test2, there will be some text printed to your terminal window. This should look like the text given in the file named model_monitor2.out that you copied from the csci131 directory. The file output from the runs will be written into a file named output2. This file will appear in the same directory into which you copied test2. The perfect output, well, the output produced by my own proj2.cc can be seen in the file, model2.out that you copied from csci131. Please view the grading header for this project to see how points will be allocated.
To submit your finished project:
2. Print out the grading header, put your name on it and staple it to the front of the hard copy of the file you submitted electronically. 3. Hand in a hard copy of the file you submitted electronically (along with the grading header). Hand this to your instructor in class on the project's due date. Note: The submit program compiles your program before accepting it. If your program does not compile successfully or if something else is wrong with your submission, the submit program will report to you that the submission failed and it will give you a (sometimes cryptic) reason for the failure. You may submit version after version of proj2.cc. Each successful submission will replace any previously submitted version. That is, only your last successfully submitted version will be visible to and will be graded by your instructor or her/his grader. Get started early and have fun! Honor code: Please review the collaboration policy on the main course webpage. Also refer to the math and CS department honor code policy. Home | | Schedule | | Assignments | | Lectures | | Resources
Constance Royden--croyden@cs.holycross.edu
|