CS 201 - Computer Science I - Fall 2008
Lab 11 - loops


Loyola College > Department of Computer Science > Dr. James Glenn > CS 201 > Labs > Lab 11

Due

Wednesday, December 3rd at 11:59pm. Labs submitted one day late will be assessed a 20% penalty. Labs will not be accepted more than one day late.

Objectives

Assignment

Create a class called TwoDice that models two six-sided dice (you can think of one die as green and one as red if you wish). Your class must have the following:

Complete the main method in DiceTest to thoroughly test your methods.

Remember to compile and test incrementally. You will need to write the two constructors and getTotal in order to perform the initial tests in DiceTest. Once those are working you can try writing the other methods one by one (it may be a good idea to write toString early).

Files

Exercises

For each method, determine if it is used to ask the object a question or if it is used to tell the object to do something. Write each question or command in plain English.

Extra Credit

Add code as appropriate to validate the values that are passed as arguments to make sure that the dice are never showing a number outside the range 1,...,6. Add code to DiceTest to test your validation.

Submissions

Submit the your source code for the TwoDice class and your completed DiceTest class as attachments to e-mail sent to your instructor. Submit the answers to the exercises on paper, as an attachment, or in the body of your e-mail.