Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/org/drtshock/NotDeliciousReason.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public enum NotDeliciousReason {
UNDERCOOKED,
OVERCOOKED,
NOT_DELICIOUS_CONDIMENT,
EXPIRED_CONDIMENT
EXPIRED_CONDIMENT,
NOT_WASHED

}
27 changes: 27 additions & 0 deletions src/main/java/org/drtshock/Potato.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
* A delicious tuber that is eaten by various peoples all over the world.
Expand Down Expand Up @@ -45,6 +46,7 @@ public List<Condiment> getCondiments() {
* @throws NotDeliciousException If the potato is not delicious
*/
public void prepare() throws NotDeliciousException {
if (!isWashed()) throw new NotDeliciousException(NotDeliciousReason.NOT_WASHED);
this.addCondiments("chives", "butter", "pepper", "salt", "tabasco", "tomatoes", "onion");
if (!this.isVegan) this.addCondiments("sour cream", "crumbled bacon", "grated cheese", "ketchup");
this.listCondiments();
Expand Down Expand Up @@ -162,6 +164,31 @@ public Tuber propagate() {
return new Potato(this.isVegan);
}

private boolean isWashed() {
return WashMethod.values()[new Random().nextInt(WashMethod.values().length)].hasBeenWashed();
}

private enum WashMethod {
QUICK_RINSE(10, 15),
SCRUBBING(30, 60),
SOAKING(300, 600);

private final int minWashTime;
private final int maxWashTime;

WashMethod(int minWashTime, int maxWashTime) {
this.minWashTime = minWashTime;
this.maxWashTime = maxWashTime;
}

public boolean hasBeenWashed() {
int washTime = (int) (Math.random() * maxWashTime);
System.out.println("Wash method: " + this.toString());
System.out.println("Wash time: " + washTime);
return washTime > minWashTime;
}
}

/**
* A type of food added to tubers.
*/
Expand Down