diff options
| author | mo <mo.khan@gmail.com> | 2019-06-04 20:19:38 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2019-06-04 20:19:38 -0600 |
| commit | 0f3a597eead0e8ddbe693c021ee63adda56ab88c (patch) | |
| tree | 0bc24e09abb6decd9573c583543a96dcc995caa0 /src | |
| parent | fc5df8dafe0c0cdeeded97e06d0a6bb06a6a656e (diff) | |
accept command line argument to run specific exercise
Diffstat (limited to 'src')
| -rw-r--r-- | src/App.java | 13 | ||||
| -rw-r--r-- | src/Q2/RockPaperScissorsLizardSpock.java | 11 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/App.java b/src/App.java index 16c2a41..6170187 100644 --- a/src/App.java +++ b/src/App.java @@ -6,17 +6,26 @@ import java.util.Scanner; public class App { public static void main(String[] args) { Scanner in = new Scanner(System.in); + Integer selection = args.length > 0 ? Integer.parseInt(args[0]) : null; + while (true) { - System.out.println("Choose exercise: (1-10)"); - switch (in.nextInt()) { + if (selection == null) { + System.out.println("Choose exercise: (1-10)"); + selection = in.nextInt(); + } + switch (selection) { case 1: Q1.ReversedSentence.main(args); break; + case 2: + Q2.RockPaperScissorsLizardSpock.main(args); + break; default: System.out.println("Bye"); System.exit(0); break; } + selection = null; } } } diff --git a/src/Q2/RockPaperScissorsLizardSpock.java b/src/Q2/RockPaperScissorsLizardSpock.java index 19f2d4f..2fbfcfa 100644 --- a/src/Q2/RockPaperScissorsLizardSpock.java +++ b/src/Q2/RockPaperScissorsLizardSpock.java @@ -15,18 +15,21 @@ public class RockPaperScissorsLizardSpock { public static final int SPOCK = 5; public int getConsecutiveWins() { - return 0; + return this.consecutiveWins; } public int getLastWinner() { - return 0; + return this.lastWinner; } public int random() { return new Random().nextInt(4) + 1; } - public void play(int player1, int player2) {} + public void play(int player1, int player2) { + int player1Roll = random(); + int player2Roll = random(); + } public static String convert(int i) { return ""; @@ -35,5 +38,7 @@ public class RockPaperScissorsLizardSpock { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Hi"); + RockPaperScissorsLizardSpock game = new RockPaperScissorsLizardSpock(); + game.play(RockPaperScissorsLizardSpock.PLAYER1, RockPaperScissorsLizardSpock.PLAYER2); } } |
