Class | Purpose |
---|---|
MiniatureGolf | The main class of the program. |
Player | A Player will play on the golf course, making several puts on each hole until they get the ball in. |
Group | One Group object will serve as a collection of an arbitrary number of Player objects. |
Course | A Course object represents nine consecutive holes on a golf course. A Group objectn can be added to the Course object, and an accessor to the Group will be provided here. |
Method | Visibility | Purpose |
---|---|---|
put | public | the put method will generate a random number number and then use a threshold to test whether or not the player hit the ball well enough to get it in the hole. |
getDone | public | this will return a boolean value. The return is true if the Player is already finished with the current hole, and false otherwise. |
newHole | public | advances the player to another hole |
setDone | private | The mutator for the done boolean variable, used by the Player object to change it's status based upon the last put and the current hole. |
Method | Visibility | Purpose |
---|---|---|
nextPlayer | public | returns, in a pre-determined successive order, the next player in the Group. In this way, the user doesn't have to worry about how we are containing an arbitrary number of Player objects. All they have to do is use a sentinel-controlled loop, calling nextPlayer in each iteration. |
morePlayersLeft | public | this method returns the boolean values that will be used as the sentinel value in the iterative loop. When this returns false, it means that the user has already accessed each Player. |
Method | Visibility | Purpose |
---|---|---|
addPlayer | public | this method is used to add a Player to a the current Course object's Group object (only one Group allowed on a Course at a time). |
getPlayers | public | returns a reference to the Group object, which can then be used to iterate through the Players in that Group |
Method | Visibility | Purpose |
---|---|---|
main | public | the required main method, which will create a course and a group of players and then begin play. |
makeCourse | private | will generate a course object and a Group object |
makePlayers | private | will generate a user-input number of Players and add them to the Group object through the Course's addPlayer method |
playGolf | private | will take user-input for the number of holes to be played, and the set up an iterative loop that simulates game play |