git test
This commit is contained in:
parent
3273adb6bb
commit
690fcb36e0
Binary file not shown.
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
public class GameClass {
|
||||
|
||||
public static void main(String[] args){
|
||||
for (int i = 0; i < 7; i++) RockPaperScissors.runGame();
|
||||
while (RockPaperScissors.playerScore < 7 ) RockPaperScissors.runGame();
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ import java.util.Scanner;
|
||||
import java.util.Random;
|
||||
|
||||
public class RockPaperScissors {
|
||||
static int computerScore = 0;
|
||||
static int playerScore = 0;
|
||||
|
||||
public static void runGame() {
|
||||
int computerInput = letComputerChoose();
|
||||
@ -13,20 +15,25 @@ public class RockPaperScissors {
|
||||
|
||||
public static void checkResults(int computerInput, int userInput) {
|
||||
|
||||
|
||||
if (computerInput == userInput) {
|
||||
System.out.println("Draw!");
|
||||
} else if (computerInput == 1 && userInput == 2
|
||||
|| computerInput == 2 && userInput == 3
|
||||
|| computerInput == 3 && userInput == 1) {
|
||||
playerScore = playerScore + 1;
|
||||
System.out.println("You win!");
|
||||
|
||||
} else if (computerInput == 2 && userInput == 1
|
||||
|| computerInput == 3 && userInput == 2
|
||||
|| computerInput == 1 && userInput == 3) {
|
||||
computerScore = computerScore + 1;
|
||||
System.out.println("Computer wins!");
|
||||
|
||||
} else {
|
||||
System.out.println("Incorrect inputs: round void");
|
||||
}
|
||||
System.out.println("The score is: " + playerScore + ":" + computerScore);
|
||||
}
|
||||
|
||||
private static String convertToWordUser(int userInput) {
|
||||
@ -70,7 +77,8 @@ public class RockPaperScissors {
|
||||
|
||||
public static int letComputerChoose() {
|
||||
Random rgen = new Random();
|
||||
int computerInput = rgen.nextInt(1, 3);
|
||||
int computerInput = rgen.nextInt(1,3);
|
||||
return computerInput;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user