EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Videos

Question
Book Icon
Chapter 5, Problem 5GZ
Program Plan Intro

Rock Paper Scissors game

Program plan:

  • Import necessary package.
  • Create a class “RockPaperScissors”,
    • Define the method “main()”,
    • Declare and initialize the necessary variables.
    • Generate the random value for the computer.
    • Assign the integer value returned from the method “parseInt()”.
    • Check whether the user value is “1”,
      • If it is true set the string as “rock”.
    • Otherwise, check whether the user value is “2”,
      • If it is true set the string as “paper”.
    • Otherwise,
      • Set the string as “scissors”.
    • Check whether the computer value is “1”,
      • If it is true set the string as “rock”.
    • Otherwise, check whether the computer value is “2”,
      • If it is true set the string as “paper”.
    • Otherwise,
      • Set the string as “scissors”.
    • Check whether the user value is “1”,
      • Check whether the computer value is “1”,
        • If it is true, set the string as “tie”.
          • Otherwise, check whether the computer value is “2”,
            • If it is true, set the string as “computer”.
          • Otherwise, set the string as “you”.
    • Check whether the user value is “2”,
      • Check whether the computer value is “2”,
        • If it is true, set the string as “tie”.
          • Otherwise, check whether the computer value is “3”,
            • If it is true, set the string as “computer”.
          • Otherwise, set the string as “you”.
    • Otherwise, check whether the computer value is “3”,
      • If it is true, set the string as “tie”.
    • Otherwise, check whether the computer value is “1”,
      • If it is true, set the string as “computer”.
    • Otherwise, set the string as “you”.
    • Display the output message in dialog box.

Blurred answer
Students have asked these similar questions
When the player clicks on the “Start Game” button, in every 1 seconds, three random alphabets will be generated and flashing on the screen (e.g. A X W) at the position as shown above. The three alphabets must not repeat at the same time (i.e. can’t have repeating alphabets – e.g. A X A). After starting a game, you can’t change the chosen alphabet.
The two friend Alpha and Beta have invented a new game called Coins&Papers. The game is played with their coins and a strip of paper divided into cells. The cells are numbered from the left, starting from 1. Alpha and Beta put some coins at some random cells on the strip, each coin in a cell. They alternatively take their turn to play the game. At each step, a player must take a coin and move it to a cell to the left of it. There is at most one coin in a cell at any time of the game. Of course, a coin cannot jump over another coin. Whoever cannot move loses the game. Beta takes her turn first. Develop a python code to find out who wins the game, if Beta could win the game, show her a winning move. If there are several winning moves, show her the winning move that uses the leftmost possible coin. If there are still several moves, show her the move that moves the coin as far as possible to the left. Sample Input: 1
The game is played in the magic maze, as shown below. The squares are flaming lava pools. If you try to cross them you will die. The grid lines are passageways and are safe to travel in. You can start at any location on the grid but must travel in the passageways. You may travel as far as you want in any direction, but once you turn, you must repeat that distance and you may only make left turns.   You may not reverse direction inside the tight passageways. You must end up at the same spot you started at. If you successful, then you gain a magic coin, which automatically appears.  You can start over again and again in a different or same starting spot and earn new magic coins, but the routes you take must differ somehow for each magic coin.  That is, no magic coins for the exact same route as previously done.  If the route varies in any way (perhaps it is the same starting location and ending location as a previous route, but longer), it will earn a new magic coin.  Mad Madame Mim has…
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
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY