From 0f3a597eead0e8ddbe693c021ee63adda56ab88c Mon Sep 17 00:00:00 2001 From: mo Date: Tue, 4 Jun 2019 20:19:38 -0600 Subject: accept command line argument to run specific exercise --- src/App.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/App.java') 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; } } } -- cgit v1.2.3