Browse Source

removed static

master
Patrik Kriska 2 years ago
parent
commit
85c042b8b7

BIN
out/production/Interaktion Projekt/GameClass.class View File


BIN
out/production/Interaktion Projekt/RockPaperScissors.class View File


+ 3
- 1
src/GameClass.java View File

@@ -1,6 +1,8 @@
public class GameClass {

public static void main(String[] args){
while (RockPaperScissors.playerScore < 7 && RockPaperScissors.computerScore < 7) RockPaperScissors.runGame();
RockPaperScissors match = new RockPaperScissors();
while (match.playerScore < 7 && match.computerScore < 7) match.runGame();
}

}

+ 8
- 9
src/RockPaperScissors.java View File

@@ -1,11 +1,10 @@
import java.util.Scanner;
import java.util.Random;
import java.util.*;

public class RockPaperScissors {
static int computerScore = 0;
static int playerScore = 0;
int computerScore = 0;
int playerScore = 0;

public static void runGame() {
public void runGame() {
int computerInput = letComputerChoose();
int userInput = letUserInput();
convertToWordUser(userInput);
@@ -13,7 +12,7 @@ public class RockPaperScissors {
checkResults(computerInput, userInput);
}

public static void checkResults(int computerInput, int userInput) {
public void checkResults(int computerInput, int userInput) {


if (computerInput == userInput) {
@@ -53,7 +52,7 @@ public class RockPaperScissors {
return userInputWord;
}

public static String convertToWordComputer(int computerInput) {
public String convertToWordComputer(int computerInput) {
String computerInputWord = "";

if (computerInput == 1) {
@@ -67,7 +66,7 @@ public class RockPaperScissors {
return computerInputWord;
}

public static int letUserInput() {
public int letUserInput() {
int userInput;
Scanner input = new Scanner (System.in);
System.out.println("1 for Rock, 2 for Paper, 3 for Scissors: ");
@@ -75,7 +74,7 @@ public class RockPaperScissors {
return userInput;
}

public static int letComputerChoose() {
public int letComputerChoose() {
Random rgen = new Random();
int computerInput = rgen.nextInt(1,4);
return computerInput;

Loading…
Cancel
Save