On This Page
Overview
This assignment uses objects to simulate a simple dice game. During this assignment, you will:
- Code a class to hold the data for a die
- Code classes that hold multiple instances of the
Die class
- Optionally, construct a class that uses static methods to test a class
^ top
Operation
If the user chooses to roll the dice, the application rolls two six-sided dice, displays the results of each, and asks if the user wants to roll again.
Welcome to the Paradise Roller application
Roll the dice? (y/n): y
Roll 1: 2 5
Craps!
Roll again? (y/n): y
Roll 2: 2 1
Roll again? (y/n): y
Roll 3: 4 6
Roll again? (y/n): y
Roll 4: 6 6
Box cars!
Roll again? (y/n): y
Roll 5: 1 1
Snake eyes!
Roll again? (y/n): n
Thanks for playing!
^ top
Specifications
- Create a class named
Die to store the data about each die. This class must contain these constructors and functions:
public:
Die(); // default to six-sided die
Die(int numSides); // variable number of sides
void roll(); // randomly picks a face value
int getValue(); // returns the face value
- Create a class named
PairOfDice to store two dice. This class must contain two instance variables of type Die and these constructors and functions:
public:
PairOfDice(); // default to six-sided dice
void roll(); // roll both dice
int getValue1(); // get value of die1
int getValue2(); // get value of die2
int getSum(); // get sum of both dice
- You can use the
rand() function to generate a random number from 1 to the number of sides on a die like this:
value = 1 + rand() % sides;
Do NOT forget to call srand(time(0)) when the application starts.
- Create a
main() function in a file named paradise.cpp that uses the PairOfDice class to roll the dice as shown in the Operation section. Add code to display special messages for craps (sum of both dice is 7), snake eyes (double 1’s), and box cars (double 6’s). For this application, assume that two six-sided dice are used.
- Do not forget to document all the code.
^ top
Extra Credit
Adding the following are worth extra credit points:
- Complete the assignment using pair programming. (1 point)
- Write a
Makefile for the application and use separate compilation. The Makefile must create an executable file named: paradise.exe (2 points)
Note: If you write a Makefile that does not work, you will get a low score because your program will not compile. Make sure you test your Makefile and the rest of your code before and after submitting. Also make sure you do not forget to submit one or more of the files.
Make certain that your README.txt file describes any extra credit attempted.
^ top
Grading Criteria
The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.
Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.
For information on grading policies, including interpretation of scores, see the course information page.
Program Compilation
- 4: Source code compiles with no errors or warnings
- 2: Source code compiles with warnings
- 0: Does not compile or wrong file turned in
Functionality
- 10: Demonstrates mastery of the assignment
- Has extra features or demonstrates techniques beyond the assignment
- Applies concepts from the lesson(s) appropriately
- Meets all specifications (see above) with particularly elegant solutions
- No errors encountered during operation
- 8: Has all the functionality expected of the assignment
- Demonstrates many techniques from the lesson
- Meets all specifications (see above)
- Implementation seems more complicated than necessary.
- May have one minor error
- 6: Has most of the functionality expected of the assignment
- Demonstrates some techniques from the lesson
- Meets all but one of the specifications (see above)
- Implementation seems excessively complicated.
- May have 2-3 minor errors
- 4: Has some of the functionality expected of the assignment
- Demonstrates some techniques from the lesson
- Meets at least 1/2 of the specifications (see above)
- Implementation seems excessively complicated.
- May have more than 3 minor errors
- 2: Serious functional problems but shows some effort and understanding
- Meets less than 1/2 of the of the specifications (see above)
- Has a major error or many minor errors
- Implementation seems very convoluted
- Demonstrates few techniques from the lesson
- 0: Does not execute or no specifications met
Code Documentation
- 4: Code is well-documented
- 3: Code has minor documentation errors
- Has 1 documentation error
- 2: Code has some documentation errors
- Has 2-3 documentation errors
- 1: Code has many documentation errors
- Has more than 3 documentation errors
- 0: No apparent attempt to document code
REAME.txt File
- 2: README.txt file submitted with specified information included
- 1: README.txt submitted but some information was not included
- 0: No README.txt submitted
Maximum Score: 20, plus extra credit
^ top
What to Turn In
Submit your assignment following the instructions for homework. Include the following items for grading:
README.txt file
paradise.cpp
- Any other source code needed to make your program function
You must submit all the files needed to make your assignment function properly. Do not assume that the instructors has any files unless explicitly stated by the instructor. Your assignment must work as submitted.
^ top
Home
| WebCT
| Announcements
| Day Schedule
| Eve Schedule
Course info
| Help
| FAQ's
| HowTo's
| Links
Last Updated: November 11 2005 @11:40:31
|