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
4 changes: 2 additions & 2 deletions src/main/java/org/drtshock/BurntException.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
public class BurntException extends Exception {

public BurntException(int degrees) {
super("Potato is badly burnt by trying to boil it at " + degrees + " degrees!!");
public BurntException(int waterDegreesFahrenheit, int waterDegreesCelsius) {
super("Potato is badly burnt by trying to boil it at (F:" + waterDegreesFahrenheit + ") (C:" + waterDegreesCelsius + ") degrees!!");
}

public BurntException(long bakeTime) {
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/org/drtshock/Potato.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ public boolean isBaked() {
* @throws BurntException if the potato has been burned during the process of cooking
*/
public boolean hasBeenBoiledInWater() throws BurntException {
int waterDegrees = (int) (Math.random() * 200);
System.out.println("Trying to boil potato at " + waterDegrees + " degrees.");
if (waterDegrees < 70) {
int waterDegreesFahrenheit = (int) (Math.random() * 200);
int waterDegreesCelsius = (int) ((waterDegreesFahrenheit - 32) / 1.8);
System.out.println("Trying to boil potato at (F:" + waterDegreesFahrenheit + ") (C:" + waterDegreesCelsius + ") degrees.");
if (waterDegreesFahrenheit < 70) {
return false;
} else if (waterDegrees > 130) {
throw new BurntException(waterDegrees);
} else if (waterDegreesFahrenheit > 130) {
throw new BurntException(waterDegreesFahrenheit, waterDegreesCelsius);
}
return true;
}
Expand Down