Condiments Must Be Delicious! (v2.0)
This commit is contained in:
parent
d714b8394c
commit
6a6da383a9
1 changed files with 13 additions and 3 deletions
|
@ -27,9 +27,13 @@ public class Potato implements Tuber {
|
||||||
if(!this.isDelicious()) throw NotDeliciousException();
|
if(!this.isDelicious()) throw NotDeliciousException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCondiments(String... names) {
|
public void addCondiments(String... names) throws NotDeliciousException {
|
||||||
synchronized (this.condiments) {
|
synchronized (this.condiments) {
|
||||||
for (String condimentName : names) this.condiments.add(new Condiment(condimentName));
|
for (String condimentName : names) {
|
||||||
|
Condiment condiment = new Condiment(condimentName, true);
|
||||||
|
if(!condiment.isDelicious()) throw new NotDeliciousException();
|
||||||
|
this.condiments.add(condiment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +71,15 @@ public class Potato implements Tuber {
|
||||||
|
|
||||||
private class Condiment {
|
private class Condiment {
|
||||||
private final String name;
|
private final String name;
|
||||||
|
private final boolean delicious;
|
||||||
|
|
||||||
public Condiment(String name) {
|
public Condiment(String name, boolean delicious) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.delicious = delicious;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDelicious() {
|
||||||
|
return delicious;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
Loading…
Reference in a new issue