-
-
Save mstefarov/6836556 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { //1. main method. In the main program declare a Scanner variable that is hooked up to System.in. | |
//You need to include the line of code import java.util.Scanner; at the top of your program. Pass the Scanner object you create as a | |
//parameter to any methods that need it. | |
//The main method should not have a lot of statements, instead it shall call other methods. | |
RockPaperScissors(); | |
} | |
public static void RockPaperScissors() { | |
System.out.println("Welcome to Rock Paper Scissors. I, Computer, will be your opponent."); | |
getName(); | |
getRounds(); | |
getRound(); | |
printResults(); | |
} | |
public static String getName() { | |
Scanner console = new Scanner(System.in); | |
System.out.print("Please type in your name and press return: "); | |
String name = console.nextLine(); | |
System.out.println(); | |
System.out.println("Welcome " + name + "."); | |
} | |
public static String getRounds(name) { | |
System.out.println("All right " + name + ". How many rounds would you like to play?"); | |
System.out.print ("Enter the number of rounds you want to play and press return: "); | |
int turns = console.nextInt(); | |
return turns; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment