Need a JavaFX version of the game called roshambo. In this game, the user plays against the computer.
1) RoShamBo is the class that represents the game play
This class only represents the game itself. This class does not interact with the user. A game is made up of many matches. A match is a single selection of rock, paper, or scissors. Thus, the RoShamBo object is described by three characteristics:
- number of computer wins
- number of user wins
- number of ties
Note that you do not need to store the user move or computer move as instance data. You are only storing the win/loss/tie counts.
- Make the instance data variables for these three characteristics and appropriate getters/setters.
- Use enums or constants to represent the possible match outcomes (user win, computer win, tie) and the possible moves (rock, paper, scissors).
- Declare and use your constants or enums throughout both your game class and the GUI class (described below).
- For example, you will need to determine a winner. To do, your code should compare whether userMove == ROCK or userMove = MoveType.ROCK, rather than userMove == 1 or userMove = "Rock"
- NOTE: Must use constants or an enum
- Make a generateComputerPlay method that generates and returns a random move by the computer.
- The return type of this method will be determined by whether you use an enum or a constant!
- Make a findWinner method that takes in two moves as parameters (the userMove and the computerMove) and determines and returns the outcome (user wins, computer wins, or tie).
- Determining the winner will require you to compare a lot of possible match-ups through a series of nested conditionals.
- The type of the parameters and the return type of the method will depend on whether you chose to use an enum or a constant!
- The method should update the appropriate win/loss/tie count (the instance data variables) before returning a value.
2) RoShamBoFX is the GUI class that interfaces with the user.
Inside RoShamBoFX.java is where we will make an object of type RoShamBo and invoke the methods from the RoShamBo class.
- The start method sets up the display and creates the instance of RoShamBo.
- The button handler/listener method will respond to the user selecting a move. Your code will go here to make the game work.
- In this method, you will invoke method from the RoShamBo class.
- Use your constants/enums from the RoShamBo class.
- Consider writing helper methods that are invoked from the handler method rather than putting all the code inside a single method.
- Here is some pseudocode for the handler/listener method. You are not required to follow this, but can if it's helpful.
get the move from the user (determine which button was clicked)
update the display of the user's move
generate a move by the computer (by invoking a method on the RoShamBO object)
update the display of the computer's move
determine the winner (by invoking a method on the RoShamBo object)
update the display of the outcome and the game stats (obtained from RoShamBo object)
3) In addition...Add support for betting:
- In RoShamBo:
- Add instance data to represent the amount the user is betting (the same amount on each match) and the user's balance of money. Man appropriate getters and setters for these instance data.
- In the findWinner method, when the number of wins/losses is updated, update the user's balance by adding or subtracting their bet amount.
- In RoShamBoFX program:
- Use a dialog box to ask the user about betting prior to the game starting.
- Hint: review the second Alert constructor to explore how to change the buttons that the user sees!
- If the user wants to bet, use a second dialog box to obtain the bet amount.
- If the user enters bad input (e.g., a non-numeric amount) or no input (e.g., closes the window), the program should still run but not display any balance information.
- Add the visual components needed to view the user's balance throughout the game.
- If the user is not betting, the program should not display any betting or balance information.
Recently Asked Questions
- hello all my name is Suresh batik former student ..i took a managerial accounting class ten years ago and have a question on how to do costing in a service
- Describe one similarity between imperial China under the Han Dynasty and imperial Rome during the first two centuries of the Common Era.
- An Anthropocentric view would best be represented by which statement? 1.The decision to remove certain invasive species in a park to protect the native