CSc 331 - Spring 2018
Lab Exercise #8
Preparation
- Create a lab8 directory to organize your files
(for you, and for electronic submission).
You may wish to copy the .java and .class files from
java files from ~hohman/331/s18/labs/lab8 into your lab8 directory.
Additional Information / Guidelines
- The Java Collections Framework is in the java.util package.
- Please follow the Java coding conventions: class names start with
a capital letter and method names begin with a lower-case letter.
Getters are named as getPrivateDataMember.
- All classes are public - and abstract as appropriate.
- All data members are private.
Introduction
You should find that it is relatively straight-forward to have your GUI call methods
on your CrapsGame controller.
The real issue is retrieving information from the game for display in the GUI.
For the purposes of this lab exercise, just add apropriate getters to the CrapsGame controller
- to return the required information. These getters may have to "reach deeper" into the application
to retrieve values - but at least the GUI class will not be aware of those details.
For examples, getD1() could return the faceValue of the first die and getChips(name) could return
the "chips" value for the player "name". It is useful to have these getters return String's.
For now, your GUI does not have to do any validation.
Exercise 1
This week's task is to add some behaviour to the GUI that you coded in
the last lab.
In particular,
-
The roll button should roll the dice - and the new face values should
be displayed in the appropriate TextFields. It would be great - but it is
not required (or expected?) - that the rest of the GUI updates as well.
-
The "Add Player" should add a player to the game
- assuming that appropriate values have been entered in the relevant TextField's.
It would be great - but it is not required (or expected?) -
that the input TextField's are initially not visible (use method setVisible).
Then clicking this button would display the 2 TextField's
and perhaps a Submit button.
Pressing Enter in the second TextField or clicking the Submit button would
trigger the "add player" event.
-
Add a Change Shooter button
- that really does change the shooter in the craps game.
Perhaps add a TextField to display the name of the current shooter.
Exercise 2
Keep adding behaviour to your GUI.
In particular, for each player,
-
The "Line Bet" button should "requestFocus" for the adjacent TextField.
-
That TextField should accept a bet amount.
When the Enter is pressed "in that TextField", the actual PassLine bet
should be placed - and the chip total for that player should update.
Exercise 3
Keep adding behaviour to your GUI.
In particular, for each player,
-
Each "Point" (for example, 5) button should "requestFocus" for the adjacent TextField.
It would be great - but it is not required (or expected?) -
that these buttons would be enabled only if the player had an existing line bet on this point
(use method setDisable).
-
That TextField should accept a bet amount.
When Enter is pressed "in that TextField", the chip total for that player should update
- if your Craps game allows that bet to be placed.
Submit:
This assignment is due at the beginning of the Tuesday lab class
(April 3) at 3:30 p.m. - and the submit program will enforce this.
- Submit your source code electronically using the command
~hohman/bin/submit 331 lab8