diff options
| author | Trent Hensler <2638275+drtshock@users.noreply.github.com> | 2021-08-06 18:56:18 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-06 18:56:18 -0500 |
| commit | 38666239cf5e53d459ece5d8f1a262ca7ecec700 (patch) | |
| tree | 9aa1fae3a492a8b50914f250e98ce3639e89af73 /src | |
| parent | d6f4991cb850afae4cbb0f855ad32a996cbb43d0 (diff) | |
| parent | be04791fea20a7442b480532ef49287d2dc22d20 (diff) | |
Merge pull request #149 from spiralw/feat/vegan
Add vegan potato
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/java/org/drtshock/Potato.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main/java/org/drtshock/Potato.java b/src/main/java/org/drtshock/Potato.java index fa0f7c7..78c93cf 100644 --- a/src/main/java/org/drtshock/Potato.java +++ b/src/main/java/org/drtshock/Potato.java @@ -11,10 +11,12 @@ import java.util.List; */ public class Potato implements Tuber { + private final boolean isVegan; private final List<Condiment> condiments = new ArrayList<>(); public static void main(String[] args) { - final Potato potato = new Potato(); + final Potato potato = new Potato(args.length == 1 && args[0].equals("--vegan")); + if (potato.isVegan) System.out.println("This potato is vegan."); try { potato.prepare(); System.out.println("Of course Potato is prepared and delicious."); @@ -23,6 +25,10 @@ public class Potato implements Tuber { } } + public Potato(boolean isVegan) { + this.isVegan = isVegan; + } + /** * Gets the condiments on this potato. * @@ -39,8 +45,8 @@ public class Potato implements Tuber { * @throws NotDeliciousException If the potato is not delicious */ public void prepare() throws NotDeliciousException { - this.addCondiments("sour cream", "chives", "butter", "crumbled bacon", "grated cheese", "ketchup", "pepper", - "salt", "tabasco", "tomatoes", "onion"); + this.addCondiments("chives", "butter", "pepper", "salt", "tabasco", "tomatoes", "onion"); + if (!this.isVegan) this.addCondiments("sour cream", "crumbled bacon", "grated cheese", "ketchup"); this.listCondiments(); if (!this.isDelicious()) throw new NotDeliciousException(NotDeliciousReason.UNDERCOOKED); } @@ -153,7 +159,7 @@ public class Potato implements Tuber { */ @Override public Tuber propagate() { - return new Potato(); + return new Potato(this.isVegan); } /** |
