Added different ways the potato can be not delicious!
This commit is contained in:
parent
ffbb869431
commit
8e47ab0d34
3 changed files with 23 additions and 3 deletions
|
@ -1,8 +1,17 @@
|
||||||
package org.drtshock;
|
package org.drtshock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An exception to describe that the potato isn't delicious!
|
||||||
|
*/
|
||||||
public class NotDeliciousException extends Exception {
|
public class NotDeliciousException extends Exception {
|
||||||
|
|
||||||
public NotDeliciousException() {
|
/**
|
||||||
|
* The reason for non-deliciousness.
|
||||||
|
*/
|
||||||
|
private NotDeliciousReason notDeliciousReason;
|
||||||
|
|
||||||
|
public NotDeliciousException(NotDeliciousReason notDeliciousReason) {
|
||||||
|
this.notDeliciousReason = notDeliciousReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
11
src/main/java/org/drtshock/NotDeliciousReason.java
Normal file
11
src/main/java/org/drtshock/NotDeliciousReason.java
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package org.drtshock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Different ways the potato can be not delicious
|
||||||
|
*/
|
||||||
|
public enum NotDeliciousReason {
|
||||||
|
|
||||||
|
NOT_BAKED,
|
||||||
|
NOT_DELICIOUS_CONDIMENT
|
||||||
|
|
||||||
|
}
|
|
@ -41,7 +41,7 @@ public class Potato implements Tuber {
|
||||||
public void prepare() throws NotDeliciousException {
|
public void prepare() throws NotDeliciousException {
|
||||||
this.addCondiments("sour cream", "chives", "butter", "crumbled bacon", "grated cheese", "ketchup", "salt", "tabasco");
|
this.addCondiments("sour cream", "chives", "butter", "crumbled bacon", "grated cheese", "ketchup", "salt", "tabasco");
|
||||||
this.listCondiments();
|
this.listCondiments();
|
||||||
if (!this.isDelicious()) throw new NotDeliciousException();
|
if (!this.isDelicious()) throw new NotDeliciousException(NotDeliciousReason.NOT_BAKED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +52,7 @@ public class Potato implements Tuber {
|
||||||
public void addCondiments(String... names) throws NotDeliciousException {
|
public void addCondiments(String... names) throws NotDeliciousException {
|
||||||
for (String condimentName : names) {
|
for (String condimentName : names) {
|
||||||
Condiment condiment = new Condiment(condimentName, true);
|
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);
|
this.getCondiments().add(condiment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue