CS 111: Fundamentals of Programming 1

Lab 5

Goals

To work with

Step 1 - Log On and Copy Lab5 folder from course folder to your directory

Step 2 - One Is Zero

One Is Zero is a simple game played with a single die. When your turn comes, you begin with 0 points for the turn. You roll the die and receive the number of points shown on the die (unless you roll 1). You may then choose to roll again and accumulate points according to the die. Your turn ends when either you choose to quit, keeping the points you have accumulated, or you roll a 1. If you roll a 1, your score for the turn is 0.

You are to write a GUI-based program to simulate the playing of the game. Your GUI should contain output fields to display the value of the roll of the die, the number of points accumulated in the current turn, the number of turns that have been played, the total points for all of the turns, and the average number of points per turn. Also there should be a button to cause another roll to occur, a button to quit this turn, and a reset button to put all of the values back to 0.

You should develop your program step by step. For example, you should get the button to roll the die to work first. Then have it accumulate points, etc.

Model versus View: In this program, you are to make a clear distinction between the data model and the view. The data model should have variables for the current roll of the die, the number of points accumulated in the current turn, the total points accumulated for completed turns, the number or turns and the average number of points per turn for the completed turns. There should be absolutely no input from the GUI fields to the data model variables in this program. The only input to the data model is via the button clicks. The output should be from the data variables to the GUI.

Methods: In this program we are going to emphasize the use of methods that you are to write and employ in your program. Here are some of the methods you should develop and use (be sure to follow these specifications):

Be sure to include Pre and Post conditions with your methods.

Once you have the basic program working correctly, add a constructor method and include code for the following features:

Getting started: There is a OneIsZero project in the Lab5 folder that you can use as a starting point.

Sample program: There is also a project called Sample in the Lab5 folder. You can execute it to see how the program should operate. Of course, I am expecting much better from you.

Step 3 - Turn in your work.

When you have completed all work on this lab, you should turn in a print out of your final program to me or the lab assistant. Be sure that you have comments with your information at the top of the programs. Part of the grade will be based on style.

You should also copy your Lab5 folder into your turnin folder.