CSc 331 - Spring 2018
Lab Exercise #8

Preparation

Additional Information / Guidelines

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,

  1. 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.
  2. 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.
  3. 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,

  1. The "Line Bet" button should "requestFocus" for the adjacent TextField.
  2. 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,

  1. 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).
  2. 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.