Task - Rock Paper Scissors Game #20
Replies: 25 comments
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
`import java.util.Scanner; public class RockPaperScissors { } |
Beta Was this translation helpful? Give feedback.
-
|
`import java.util.Scanner; class Mediator implements RockPaperScissors{ } class Computer extends Mediator{ } class Human extends Mediator{ } public class RPSDriver{ |
Beta Was this translation helpful? Give feedback.
-
|
import java.util.Scanner; class GameDriver { } |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
`import java.util.Scanner; abstract class RockPaperScissor { } class WinnerCheck extends RockPaperScissor { } class Main1 { }` |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
`import java.util.Scanner; class Scissor { } |
Beta Was this translation helpful? Give feedback.
-
|
`import java.util.*; public class RockPaperScissorsGame { } |
Beta Was this translation helpful? Give feedback.
-
|
`import java.util.Scanner; class Game { } class RockPaper { }` |
Beta Was this translation helpful? Give feedback.
-
|
`import java.util.Scanner; void computerChoice() { } void helper() { } class RockGame { } |
Beta Was this translation helpful? Give feedback.
-
|
ROCK PAPER SISSOR import java.util.Scanner; } |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
import java.util.Scanner;
import java.util.*;
class RockPaperScissor {
static int randomNumber() {
int num=(int)((Math.random()*3) + 1);
return num;
}
static void choice(int ch) {
switch (ch) {
case 1:
System.out.println("Rock");
break;
case 2:
System.out.println("Paper");
break;
case 3:
System.out.println("Scissor");
}
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Welcome to Rock Paper Scissor Game");
char continues;
int choice;
int random;
while (true) {
System.out.println("Choose your option :\n1) Rock\t2)Paper\t3)Scissor");
choice = scanner.nextInt();
random = randomNumber();
System.out.print("The computer choosees ");
choice(random);
if (choice == random) {
System.out.println("It's a draw.\nRematch\n\n");
continue;
}
if ((choice == 1 && random == 3) || (choice == 2 && random == 1) || (choice == 3 && random == 2)) {
System.out.println("Yeee!!! You Won");
} else {
System.out.println("Sorry!!! You lost");
}
System.out.println("Want to continue?(y/n)");
continues = scanner.next().charAt(0);
if (continues == 'y') {
System.out.println("\n\n");
} else {
System.out.println("Thank you for playing!\n\n");
break;
}
}
}
}
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows:
When the program begins, a random integer number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don’t display the computer’s choice yet)
The user enters his or her choice of “rock”, “paper”, or “scissors” at the keyboard. You can use a menu if you prefer)
The computer’s choice is displayed.
A winner is selected according to the following rules:
Divide the program into functions that perform each major task.
Beta Was this translation helpful? Give feedback.
All reactions