From dcb4331b7bcff63653b60d133f3cdee22a007b2b Mon Sep 17 00:00:00 2001 From: Kyle Clemens Date: Thu, 1 Oct 2015 17:05:13 -0400 Subject: [PATCH 1/6] Updated: Ignore IDEA files --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 889cb7f..e4d0c4e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ target/ *.class .classpath -.project \ No newline at end of file +.project +.idea +*.iml From 4188d9bbca5a68b7eaad81d47eca315dc2acdabc Mon Sep 17 00:00:00 2001 From: Kyle Clemens Date: Thu, 1 Oct 2015 17:06:08 -0400 Subject: [PATCH 2/6] Added: .gitattributes to standardize line endings --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..aecd8c8 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +text eol=lf +*.java text From 0c64019755405278ac97b2ad689838df3d050959 Mon Sep 17 00:00:00 2001 From: Kyle Clemens Date: Thu, 1 Oct 2015 17:14:10 -0400 Subject: [PATCH 3/6] Fixed: Remove useless return --- src/main/java/org/drtshock/Potato.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/drtshock/Potato.java b/src/main/java/org/drtshock/Potato.java index a4a4ca0..6f29a36 100644 --- a/src/main/java/org/drtshock/Potato.java +++ b/src/main/java/org/drtshock/Potato.java @@ -17,7 +17,6 @@ public class Potato implements Tuber { System.out.println("Of course potato is prepared and delicious."); } catch (NotDeliciousException e) { System.err.println("Fatal error! How could potato not be delicious?"); - return; } } From a60ed6afd7dc0c018a01046addc946e39f8b1e1b Mon Sep 17 00:00:00 2001 From: Kyle Clemens Date: Thu, 1 Oct 2015 17:15:13 -0400 Subject: [PATCH 4/6] Added: Sweet JavaDucks --- src/main/java/org/drtshock/Potato.java | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/main/java/org/drtshock/Potato.java b/src/main/java/org/drtshock/Potato.java index 6f29a36..d7c35a1 100644 --- a/src/main/java/org/drtshock/Potato.java +++ b/src/main/java/org/drtshock/Potato.java @@ -6,6 +6,9 @@ import java.net.URL; import java.util.ArrayList; import java.util.List; +/** + * A delicious tuber that is eaten by peoples all over the world. + */ public class Potato implements Tuber { private final List condiments = new ArrayList(); @@ -20,24 +23,43 @@ public class Potato implements Tuber { } } + /** + * Prepares the potato for consumption. Adds various condiments and prints them to stdout. Ensures that the potato + * is delicious. If it is not, a {@link NotDeliciousException} is thrown. + * + * @throws NotDeliciousException If the potato is not delicious + */ public void prepare() throws NotDeliciousException { this.addCondiments("sour cream", "chives", "butter", "crumbled bacon", "grated cheese", "ketchup", "salt", "tabasco"); this.listCondiments(); if(!this.isDelicious()) throw new NotDeliciousException(); } + /** + * Adds condiments to the potato. + * + * @param names Names of the condiments to add + */ public void addCondiments(String... names) { for (String condimentName : names) { this.condiments.add(new Condiment(condimentName)); } } + /** + * Prints the names of the condiments on this potato to stdout. + */ public void listCondiments() { for (Condiment condiment : this.condiments) { System.out.println(condiment.getName()); } } + /** + * Checks if the potato is put into the oven. + * + * @return true if potato is in the oven, false if otherwise + */ public boolean isPutIntoOven() { try { final URL url = new URL("https://www.google.com/search?q=potato"); @@ -52,20 +74,38 @@ public class Potato implements Tuber { } } + /** + * Checks if this potato is baked. Returns the result of {@link #isPutIntoOven()}. + * + * @return true if this potato is baked, false if otherwise + */ public boolean isBaked() { return this.isPutIntoOven(); } + /** + * Checks if this potato is delicious. Returns the result of {@link #isBaked()}. + * + * @return true if this potato is delicious, false if otherwise + */ @Override public boolean isDelicious() { return this.isBaked(); } + /** + * Propagates a new potato. + * + * @return A new potato + */ @Override public Tuber propagate() { return new Potato(); } + /** + * A type of food added to tubers. + */ private class Condiment { private final String name; @@ -73,6 +113,11 @@ public class Potato implements Tuber { this.name = name; } + /** + * Gets the name of this condiment. + * + * @return Name + */ public String getName() { return this.name; } From 306ddeaab560c3304559bc41a3fa39e04bf83535 Mon Sep 17 00:00:00 2001 From: Kyle Clemens Date: Thu, 1 Oct 2015 17:15:23 -0400 Subject: [PATCH 5/6] Updated: Bad formatting --- src/main/java/org/drtshock/Potato.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/drtshock/Potato.java b/src/main/java/org/drtshock/Potato.java index d7c35a1..4110420 100644 --- a/src/main/java/org/drtshock/Potato.java +++ b/src/main/java/org/drtshock/Potato.java @@ -32,7 +32,7 @@ public class Potato implements Tuber { public void prepare() throws NotDeliciousException { this.addCondiments("sour cream", "chives", "butter", "crumbled bacon", "grated cheese", "ketchup", "salt", "tabasco"); this.listCondiments(); - if(!this.isDelicious()) throw new NotDeliciousException(); + if (!this.isDelicious()) throw new NotDeliciousException(); } /** From 0767c48220adb5314ebf6b945d07249a513147aa Mon Sep 17 00:00:00 2001 From: Kyle Clemens Date: Thu, 1 Oct 2015 17:15:41 -0400 Subject: [PATCH 6/6] Added: #getCondiments() --- src/main/java/org/drtshock/Potato.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/drtshock/Potato.java b/src/main/java/org/drtshock/Potato.java index 4110420..d74b016 100644 --- a/src/main/java/org/drtshock/Potato.java +++ b/src/main/java/org/drtshock/Potato.java @@ -23,6 +23,15 @@ public class Potato implements Tuber { } } + /** + * Gets the condiments on this potato. + * + * @return Mutable list of condiments + */ + public List getCondiments() { + return this.condiments; + } + /** * Prepares the potato for consumption. Adds various condiments and prints them to stdout. Ensures that the potato * is delicious. If it is not, a {@link NotDeliciousException} is thrown. @@ -42,15 +51,17 @@ public class Potato implements Tuber { */ public void addCondiments(String... names) { for (String condimentName : names) { - this.condiments.add(new Condiment(condimentName)); + this.getCondiments().add(new Condiment(condimentName)); } } /** * Prints the names of the condiments on this potato to stdout. + * + * @see #getCondiments() */ public void listCondiments() { - for (Condiment condiment : this.condiments) { + for (Condiment condiment : this.getCondiments()) { System.out.println(condiment.getName()); } }