mirror of
https://github.com/UnlegitDqrk/Potato.git
synced 2025-10-02 06:30:15 +02:00
Add NotDeliciousException
This commit is contained in:
8
src/main/java/org/drtshock/NotDeliciousException.java
Normal file
8
src/main/java/org/drtshock/NotDeliciousException.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package org.drtshock;
|
||||||
|
|
||||||
|
public class NotDeliciousException extends Exception {
|
||||||
|
|
||||||
|
public NotDeliciousException() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -12,14 +12,19 @@ public class Potato implements Tuber {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
final Potato potato = new Potato();
|
final Potato potato = new Potato();
|
||||||
if (potato.prepare()) System.out.println("Of course potato is prepared and delicious.");
|
try {
|
||||||
else System.err.println("Fatal error! How could potato not be delicious?");
|
potato.prepare();
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean prepare() {
|
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();
|
||||||
return this.isDelicious();
|
if(!this.isDelicious()) throw NotDeliciousException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCondiments(String... names) {
|
public void addCondiments(String... names) {
|
||||||
|
Reference in New Issue
Block a user