You will create a JavaFX version of the game called roshambo. In this game, the user plays against the computer.

onoonono
timer Asked: May 16th, 2018

Question Description

1. Play one of the three objects against your opponent. You and your opponent (the computer) will choose one of 3 objects—either rock, paper or scissors. You’ll then name a winner based on which object each played.

2. Determine the winner. After you’ve both played an object, look to see who’s won. Each object wins against one shape and loses to another. For instance, rock “crushes” scissors but is “covered” by paper, paper “covers” rock but is “cut” by scissors, and scissors is “crushed” by rock but “cuts” paper. The player who picks the stronger of the two objects is the winner. If both players throw the same object, it’s a tie.

Unformatted Attachment Preview

5/15/2018 Assignment 8: Not Accepted Late Assignment 8: Not Accepted Late Submit Assignment Due Tuesday by 5pm Points 5 Submitting a file upload Assignment 8: NOT ACCEPTED LATE Purpose For this final program, we will use almost all of the programming constructs we have seen in this course: Data, Writing Classes, Conditionals, Object­Oriented Design, and GUIs. Background Thought Here are 4 advantages of object­oriented programming we have seen in CS111B: 1. Modularity for easier troubleshooting 2. Reuse of code through inheritance 3. Flexibility through polymorphism 4. Effective problem solving Instruc ons You will create a JavaFX version of the game called roshambo. In this game, the user plays against the computer. Here are the rules of the game: 1. Play one of the three objects against your opponent. You and your opponent (the computer) will choose one of 3 objects—either rock, paper or scissors. You’ll then name a winner based on which object each played. 2. Determine the winner. After you’ve both played an object, look to see who’s won. Each object wins against one shape and loses to another. For instance, rock “crushes” scissors but is “covered” by paper, paper “covers” rock but is “cut” by scissors, and scissors is “crushed” by rock but “cuts” paper. The player who picks the stronger of the two objects is the winner. If both players throw the same object, it’s a tie. https://ccsf.instructure.com/courses/13978/assignments/115614 1/5 5/15/2018 Assignment 8: Not Accepted Late Program Design The user clicks a button to make their move (rock, paper, or scissors). The program randomly generates a move for the computer. The program uses images to display the user's move and the computer's move. The program displays the outcome of the match. The program keeps track of and displays the number of computer wins, user wins, and ties. I have provided an executable jar sample file here: RoShamBo.jar NOTE: To run a jar file at sytem prompt: java ­jar RoShamBo.jar You will create 2 classes: 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. For RoShamBo.java: Write 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 this, your code should compare whether userMove == ROCK or userMove = MoveType.ROCK, rather than userMove == 1 or userMove = "Rock" NOTE: You must use constants or an enum to get full credit for the project. Write 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! Write 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. https://ccsf.instructure.com/courses/13978/assignments/115614 2/5 5/15/2018 Assignment 8: Not Accepted Late 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 (see Chapter 4.7 for more on Images and 5.7 For Determining Event Sources using Buttons) Inside RoShamBoFX.java is where we will create an object of type RoShamBo and invoke the methods from the RoShamBo class. To help with GUI layout, a shell of RoShamBoFX.java is provided as is 3 .jpg image files (feel free to use your own images) in this zipped file: Lesson8.zip 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) EXTRA CREDIT: Add support for betting (see Chapter 9 for info on Dialog Boxes): 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. Write 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 (Alert) to ask the user about betting prior to the game starting. https://ccsf.instructure.com/courses/13978/assignments/115614 3/5 5/15/2018 Assignment 8: Not Accepted Late 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 (TextInputDialog) 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. Object‑Oriented Design The goal of this assignment is to make sure that each class handles the appropriate tasks: The RoShamBo class should only handle the game ­ it shouldn't have any interaction with the user. The RoShamBoFX class should only interact with the user ­ it doesn't know how to play the game. It only knows how to get info from the user (in the form of a button click or dialog box), send that info to the game (by invoking a method on the game object), get info back from the game (through values returned from the game's methods), and display info to the user (using the JavaFX elements). Make sure you preserve this object­oriented idea throughout your program! Submi ng Your Work FOR CREDIT Once you have the code working on your own machine, submit your assignment on Canvas (to avoid late penalty submission must be completed no later than 5pm on due date). But first... a) zip your source code and byte code files into an archive (using your last name): LastName8.zip ­ RoShamBo.java and RoShamBo.class ­ RoShamBoFX.ava and RoShamBoFX.class b) Submit LastName8.zip onto Canvas. NOTE: All group members MUST submit the same zipped for to receive a grade. c) Don't forget all classes/methods need javadoc comments and you also need a high­level algorithm at top of driver program in a comment Note: If you do not submit assignment successfully using Canvas, I cannot give you a grade. I cannot give you a grade unless your code compiles. The submission must be completed NO LATER THAN 5pm on due date. GIVE YOURSELF TIME TO SUBMIT. Code must compile to be given any credit. THIS ASSIGNMENT NOT ACCEPTED LATE https://ccsf.instructure.com/courses/13978/assignments/115614 4/5 5/15/2018 https://ccsf.instructure.com/courses/13978/assignments/115614 Assignment 8: Not Accepted Late 5/5
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Similar Content

Related Tags

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors