Skip to content

Commit

Permalink
Added different ways the potato can be not delicious!
Browse files Browse the repository at this point in the history
  • Loading branch information
hfreeb committed Oct 28, 2015
1 parent ffbb869 commit 8e47ab0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/main/java/org/drtshock/NotDeliciousException.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package org.drtshock;

/**
* An exception to describe that the potato isn't delicious!
*/
public class NotDeliciousException extends Exception {

public NotDeliciousException() {
/**
* The reason for non-deliciousness.
*/
private NotDeliciousReason notDeliciousReason;

public NotDeliciousException(NotDeliciousReason notDeliciousReason) {
this.notDeliciousReason = notDeliciousReason;
}

}
11 changes: 11 additions & 0 deletions src/main/java/org/drtshock/NotDeliciousReason.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.drtshock;

/**
* Different ways the potato can be not delicious
*/
public enum NotDeliciousReason {

NOT_BAKED,
NOT_DELICIOUS_CONDIMENT

}
4 changes: 2 additions & 2 deletions src/main/java/org/drtshock/Potato.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public List<Condiment> getCondiments() {
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(NotDeliciousReason.NOT_BAKED);
}

/**
Expand All @@ -52,7 +52,7 @@ public void prepare() throws NotDeliciousException {
public void addCondiments(String... names) throws NotDeliciousException {
for (String condimentName : names) {
Condiment condiment = new Condiment(condimentName, true);
if (!condiment.isDelicious()) throw new NotDeliciousException();
if (!condiment.isDelicious()) throw new NotDeliciousException(NotDeliciousReason.NOT_DELICIOUS_CONDIMENT);
this.getCondiments().add(condiment);
}
}
Expand Down

0 comments on commit 8e47ab0

Please sign in to comment.