MindTapV2.0 for Farrell's Java Programming with 2021 Updates, 9th Edition [Instant Access], 1 term
MindTapV2.0 for Farrell's Java Programming with 2021 Updates, 9th Edition [Instant Access], 1 term
9th Edition
ISBN: 9780357505540
Author: Farrell; Joyce
Publisher: Cengage Learning US
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 7, Problem 2GZ
Program Plan Intro

Enhancement of Rock Paper Scissors game

Program plan:

  • Import necessary packages.
  • Create a class “RockPaperScissors2”,
    • Define the “main()” method.
      • Declare a variable.
      • Declare and initialize variables.
      • Execute the following,
        • Create “Scanner” object.
        • Generate Random number.
        • Prompt the user to enter Rock or Paper or Scissor.
        • Increment the number of games.
        • Get the user input.
        • Take the first two characters of user input.
        • Convert it into upper case.
        • Execute switch statement,
        • If the random number is “3”.
          • Print a message.
          • Check if first two characters of user input is "PA", print a message, and increment the number of loses.
          • Else,
            • Check if first two characters of user input is "SC", print a message, and increment the number of ties.
          • Else,
            • Check if first two characters of user input is "RO", print a message, and increment the number of wins.
        • If the random number is “1”,
          • Print a message.
          • Check if first two characters of user input is "SC", print a message, and increment the number of loses.
          • Else,
            • Check if first two characters of user input is "RO", print a message, and increment the number of ties.
          • Else,
            • Check if first two characters of user input is "PA", print a message, and increment the number of wins.
        • If the random number is “2”,
          • Print a message.
          • Check if first two characters of user input is "SC", print a message, and increment the number of wins.
          • Else,
            • Check if first two characters of user input is "RO", print a message, and increment the number of loses.
          • Else,
            • Check if first two characters of user input is "PA", print a message, and increment the number of ties.
        • For a default case, print a message as “Invalid input.”.
      • Ask the user if they want to repeat or not,
      • Get the opinion.
    • Check the condition in exit “while” loop.
      • Print total number games.
      • Print total number wins.
      • Print total number loses.
      • Print total number ties.

Blurred answer
Students have asked these similar questions
Change the following code so that it checks the following 3 conditions: 1. there is no space between each cells (imgs) 2. even if it is resized, the components wouldn't disappear 3. The GameGUI JPanel takes all the JFrame space, so that there shouldn't be extra space appearing in the frame other than the game.   Main():         Labyrinth labyrinth = new Labyrinth(10);         Player player = new Player(9, 0);        Dragon dragon = new Dragon(9, 9);         JFrame frame = new JFrame("Labyrinth Game");        GameGUI gui = new GameGUI(labyrinth, player, dragon);         frame.add(gui);        frame.setSize(600, 600);        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);        frame.setVisible(true);   public class GameGUI extends JPanel {    private final Labyrinth labyrinth;    private final Player player;    private final Dragon dragon; //labyrinth, player, dragon are just public classes     private final ImageIcon playerIcon = new ImageIcon("data/images/player.png");…
Make the following game user friendly with GUI, with some simple graphics. The GUI should be in another seperate class, with some ImageIcon, and Game class should be added into the pane. The following code works as this: The objective of the player is to escape from this labyrinth. The player starts at the bottom left corner of the labyrinth. He has to get to the top right corner of the labyrinth as fast he can, avoiding a meeting with the evil dragon. The player can move only in four directions: left, right, up or down. There are several escape paths in all labyrinths. The player’s character should be able to moved with the well known WASD keyboard buttons. If the dragon gets to a neighboring field of the player, then the player dies. Because it is dark in the labyrinth, the player can see only the neighboring fields at a distance of 3 units.  Cell Class: public class Cell { private boolean isWall; public Cell(boolean isWall) { this.isWall = isWall; } public boolean isWall() { return…
Discuss the negative and positive impacts or information technology in the context of your society. Provide two references along with with your answer
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Expressions in C++ | C++ tutorial for beginners; Author: Tutorial Mart;https://www.youtube.com/watch?v=XHbsZGpmRc8;License: Standard YouTube License, CC-BY
expression in python # python expressions; Author: Abhishek Tripathi;https://www.youtube.com/watch?v=Cc-kJGRjH6k;License: Standard Youtube License