Skip to content

Instantly share code, notes, and snippets.

@mstefarov
Forked from anonymous/gist:6836552
Created October 5, 2013 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mstefarov/6836556 to your computer and use it in GitHub Desktop.
Save mstefarov/6836556 to your computer and use it in GitHub Desktop.
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