diff --git a/README.md b/README.md index 3e258ece3..14d017d9b 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,11 @@ * To create a casino simulation. ## Minimum Viable Product (MVP) -* Your application must have at the very least 3 games: +* Your application must have at the very least 4 games: * Go Fish a card game * BlackJack a card game * Craps a dice game + * An additional dice game ## Specs * The project should include some concept of @@ -14,14 +15,17 @@ * `Player` objects should be created upon input from a user. * `Game` interface * Contract which ensures that a class enforces some aspect of _playing_. - * `Gamble` interface - * Contract which ensures that a class enforces some aspect of _waging money_. + * `GamblingGame` interface + * Contract which ensures that a game enforces some aspect of _waging money_. + * `GamblingPlayer` interface + * Contract which ensures that a player has some ability to _wage money_. + * The `utilities.Console` class should NOT be modified. It should be _wrapped_ or encapsulated by other classes. ## Developmental Notes -* Go fish is a friendly game and should not involve gambling. -* `BlackJack` and `GoFish` are both Card Games and should therefore inherit from a common `CardGame`. +* `GoFish` is a friendly game and should not involve gambling. +* `BlackJack` and `GoFish` are both card games and should therefore inherit from a common `CardGame`. * Any common logic or fields between the games should live CardGame class, **not** BlackJack **nor** GoFish. * You must have a completed and approved UML diagram before you proceed to do any development * All public methods should be tested. diff --git a/src/main/java/io/zipcoder/casino/Casino.java b/src/main/java/io/zipcoder/casino/Casino.java index 78aa54655..16ca0dd74 100644 --- a/src/main/java/io/zipcoder/casino/Casino.java +++ b/src/main/java/io/zipcoder/casino/Casino.java @@ -3,6 +3,6 @@ public class Casino { public static void main(String[] args) { - + // write your tests before you start fucking with this } } diff --git a/src/main/java/io/zipcoder/casino/utilities/Console.java b/src/main/java/io/zipcoder/casino/utilities/Console.java new file mode 100644 index 000000000..ab896c956 --- /dev/null +++ b/src/main/java/io/zipcoder/casino/utilities/Console.java @@ -0,0 +1,61 @@ +package io.zipcoder.casino.utilities; + + +import java.io.InputStream; +import java.io.PrintStream; +import java.util.Scanner; + +/** + * You are advised against modifying this class. + */ +public final class Console { + private final Scanner input; + private final PrintStream output; + + public Console(InputStream in, PrintStream out) { + this.input = new Scanner(in); + this.output = out; + } + + public void print(String val, Object... args) { + output.format(val, args); + } + + public void println(String val, Object... vals) { + print(val + "\n", vals); + } + + public String getStringInput(String prompt, Object... args) { + println(prompt, args); + return input.nextLine(); + } + + public Double getDoubleInput(String prompt, Object... args) { + String stringInput = getStringInput(prompt, args); + try { + Double doubleInput = Double.parseDouble(stringInput); + return doubleInput; + } catch (NumberFormatException nfe) { // TODO - Eliminate recursive nature + println("[ %s ] is an invalid user input!", stringInput); + println("Try inputting a numeric value!"); + return getDoubleInput(prompt, args); + } + } + + public Long getLongInput(String prompt, Object... args) { + String stringInput = getStringInput(prompt, args); + try { + Long longInput = Long.parseLong(stringInput); + return longInput; + } catch (NumberFormatException nfe) { // TODO - Eliminate recursive nature + println("[ %s ] is an invalid user input!", stringInput); + println("Try inputting an integer value!"); + return getLongInput(prompt, args); + } + } + + public Integer getIntegerInput(String prompt, Object... args) { + return getLongInput(prompt, args).intValue(); + } +} +