From f4e399313300ee726ee247a4a757314ff772eb43 Mon Sep 17 00:00:00 2001 From: asdfasdf Date: Wed, 18 Sep 2019 11:54:52 -0700 Subject: [PATCH] Clear up Main. --- src/main/ui/Main.java | 58 ++++--------------------------------------- 1 file changed, 5 insertions(+), 53 deletions(-) diff --git a/src/main/ui/Main.java b/src/main/ui/Main.java index afbbd5f..7c2686c 100644 --- a/src/main/ui/Main.java +++ b/src/main/ui/Main.java @@ -12,64 +12,16 @@ public class Main { //Constructor, not the java main public Main(String[] args) { + //init options, it will load defaults + //from resource xml //options = new Options(); - System.out.println("Welcome to " + PROGRAM_NAME + "!"); - guess(); - end(); + // + //parse args, uses + //options.parseArgs(args); } // java main public static void main(String[] args) { new Main(args); } - - public void guess() { - Random rand = new Random(); - while (true) { - int range = rand.nextInt(1000); - int secret = rand.nextInt(range); - System.out.println("Can you guess my number? [0 - " + range + "]"); - System.out.println("Enter -1 to end"); - int user = getUserInt(); - if (user < 0) { - break; - } else { - guessResult(user, secret); - } - } - } - - public int getUserInt() { - Scanner scan = new Scanner(System.in); - int result = 0; - while (true) { - if (scan.hasNextInt()) { - result = scan.nextInt(); - break; - } else { - System.out.println("Try again?"); - scan.nextLine(); - } - } - return result; - } - - public void guessResult(int user, int secret) { - if (user < secret || user > secret) { - this.games++; - System.out.println("Too bad. You guessed " - + secret + " with " + user + "."); - } else { - this.games++; - this.win++; - System.out.println("Wonderful! You have correctly guessed: " - + secret + " with " + user + "!"); - } - } - - public void end() { - System.out.println("You have won: " + this.win + " out of " + this.games - + "!"); - System.out.println("Thank you for playing this game! Bye!"); - } }