From 9d0544e8dc0646e737ea1fde9866a860fef25fe9 Mon Sep 17 00:00:00 2001 From: Kyle Clemens Date: Sun, 10 Nov 2013 02:37:13 -0500 Subject: [PATCH] Added: Tuber! Also did some other stuff. --- src/Potato.java | 25 ++++++++++++++----------- src/Tuber.java | 3 +++ 2 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 src/Tuber.java diff --git a/src/Potato.java b/src/Potato.java index 51167de..399cdda 100644 --- a/src/Potato.java +++ b/src/Potato.java @@ -1,30 +1,29 @@ import java.util.List; import java.util.ArrayList; -public class Potato { +public class Potato implements Tuber { private final List condiments = new ArrayList(); public static void main(String[] args) { Potato potato = new Potato(); - Glados glados = new Glados(); + GLaDOS glados = new GLaDOS(); if (potato.prepare()) System.out.println("Of course potato is prepared and delicious."); - else System.out.println("Fatal error! How could potato not be delicious?"); + else System.err.println("Fatal error! How could potato not be delicious?"); } public boolean prepare() { - this.addCondiment("sour cream"); - this.addCondiment("chives"); - this.addCondiment("butter"); + this.addCondiments("sour cream", "chives", "butter"); return this.isDelicious(); } - public void addCondiment(String name) { + public void addCondiments(String... names) { synchronized (condiments) { - condiments.add(new Condiment(name)); + for (String condimentName : names) condiments.add(new Condiment(condimentName)); } } + @Override public boolean isDelicious() { return true; // obviously, potatos are always delicious } @@ -41,10 +40,14 @@ public class Potato { } } - private static class Glados extends Potato { - public Glados() - { + private static class GLaDOS extends Potato { + public GLaDOS() { System.out.println("Oh hi, how are you holding up? BECAUSE I'M A POTATO... clap clap clap... oh good, my slow clap processor made it into this thing, at least we have that."); } + + @Override + public boolean isDelicious() { + return false; // robots are not delicious + } } } diff --git a/src/Tuber.java b/src/Tuber.java new file mode 100644 index 0000000..ec36f28 --- /dev/null +++ b/src/Tuber.java @@ -0,0 +1,3 @@ +public interface Tuber { + public boolean isDelicious(); +}