Skip to content
Snippets Groups Projects
Commit 0766472e authored by Einar Stamland's avatar Einar Stamland
Browse files

rpsFinished

parent 81de9a53
No related branches found
No related tags found
No related merge requests found
......@@ -2,8 +2,10 @@ package rockPaperScissors;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.Scanner;
public class RockPaperScissors {
public static void main(String[] args) {
......@@ -25,7 +27,53 @@ public class RockPaperScissors {
public void run() {
// TODO: Implement Rock Paper Scissors
}
while (true){
// Imput Choise
System.out.println("Let's play round "+ roundCounter);
roundCounter++;
System.out.println("Your choice (Rock/Paper/Scissors)?");
String MyChoice = sc.nextLine();
if (!rpsChoices.contains(MyChoice)){
System.out.println("I do not understand"+MyChoice + ". Could you try again?");
}
//Computer Choise
String ComputerChoise = rpsChoices.get(new Random().nextInt(rpsChoices.size()));
//Compare Choise and Add score
if (MyChoice.equals(ComputerChoise)) {
System.out.println("Human chose "+MyChoice+", computer chose "+ComputerChoise+". It's a tie!");
}else if ((MyChoice.equals("Rock") && ComputerChoise.equals("Scissors")) ||
(MyChoice.equals("Paper") && ComputerChoise.equals("Rock")) ||
(MyChoice.equals("Scissors") && ComputerChoise.equals("Paper"))){
System.out.println("Human chose "+MyChoice+", computer chose "+ComputerChoise+". Human wins!");
humanScore++;
}else {
System.out.println("Human chose "+MyChoice+", computer chose "+ComputerChoise+". Computer wins!");
computerScore++;
}
System.out.println("Score: human "+ humanScore+", computer "+ computerScore);
System.out.println("Do you wish to continue playing? (y/n)?");
String play = sc.nextLine();
if (play.equals("n")){
break;
}
}
//Continiuse play
System.out.println("Bye bye :)");
}
/**
* Reads input from console with given prompt
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment