diff options
| author | rtainc <me@rtainc.in> | 2014-10-04 22:14:26 -0400 |
|---|---|---|
| committer | rtainc <me@rtainc.in> | 2014-10-04 22:14:26 -0400 |
| commit | 6a6da383a9ce8fda543f9bb7d32bb91f12ad861a (patch) | |
| tree | 3124a4ae7964ae768976225685ca4c74d4d6ab6f | |
| parent | d714b8394c1bb8fbc1bb52a7eac741cbdf247462 (diff) | |
Condiments Must Be Delicious! (v2.0)
| -rw-r--r-- | src/main/java/org/drtshock/Potato.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/main/java/org/drtshock/Potato.java b/src/main/java/org/drtshock/Potato.java index 173340a..0aa90a8 100644 --- a/src/main/java/org/drtshock/Potato.java +++ b/src/main/java/org/drtshock/Potato.java @@ -27,9 +27,13 @@ public class Potato implements Tuber { if(!this.isDelicious()) throw NotDeliciousException(); } - public void addCondiments(String... names) { + public void addCondiments(String... names) throws NotDeliciousException { synchronized (this.condiments) { - for (String condimentName : names) this.condiments.add(new Condiment(condimentName)); + for (String condimentName : names) { + Condiment condiment = new Condiment(condimentName, true); + if(!condiment.isDelicious()) throw new NotDeliciousException(); + this.condiments.add(condiment); + } } } @@ -67,9 +71,15 @@ public class Potato implements Tuber { private class Condiment { private final String name; + private final boolean delicious; - public Condiment(String name) { + public Condiment(String name, boolean delicious) { this.name = name; + this.delicious = delicious; + } + + public boolean isDelicious() { + return delicious; } public String getName() { |
