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

public class GameClass { public class GameClass {


public static void main(String[] args){ 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

import java.util.Scanner;
import java.util.Random;
import java.util.*;


public class RockPaperScissors { 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 computerInput = letComputerChoose();
int userInput = letUserInput(); int userInput = letUserInput();
convertToWordUser(userInput); convertToWordUser(userInput);
checkResults(computerInput, userInput); checkResults(computerInput, userInput);
} }


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




if (computerInput == userInput) { if (computerInput == userInput) {
return userInputWord; return userInputWord;
} }


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


if (computerInput == 1) { if (computerInput == 1) {
return computerInputWord; return computerInputWord;
} }


public static int letUserInput() {
public int letUserInput() {
int userInput; int userInput;
Scanner input = new Scanner (System.in); Scanner input = new Scanner (System.in);
System.out.println("1 for Rock, 2 for Paper, 3 for Scissors: "); System.out.println("1 for Rock, 2 for Paper, 3 for Scissors: ");
return userInput; return userInput;
} }


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

Loading…
Cancel
Save