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/App.java | |
| parent | fc5df8dafe0c0cdeeded97e06d0a6bb06a6a656e (diff) | |
accept command line argument to run specific exercise
Diffstat (limited to 'src/App.java')
| -rw-r--r-- | src/App.java | 13 |
1 files changed, 11 insertions, 2 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; } } } |
