Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split BurntException into two subclasses #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
12 changes: 12 additions & 0 deletions src/main/java/org/drtshock/BakedTooLongException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.drtshock;

/**
* An exception to describe that our potato was baked too long!
*/
public class BakedTooLongException extends BurntException {

public BakedTooLongException(long bakeTime) {
super("Potato is badly burnt by baking for too long!! (" + bakeTime + "ms)");
}

}
12 changes: 12 additions & 0 deletions src/main/java/org/drtshock/BoiledTooHotException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.drtshock;

/**
* An exception to describe that our potato was boiled too hot!
*/
public class BoiledTooHotException extends BurntException {

public BoiledTooHotException(int degrees) {
super("Potato is badly burnt by trying to boil it at " + degrees + " degrees!!");
}

}
10 changes: 5 additions & 5 deletions src/main/java/org/drtshock/BurntException.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package org.drtshock;

/**
* An exception to describe that something went wrong with our oven!
* An exception to describe that our potato was burnt!
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also fixed this comment.

*/
public class BurntException extends Exception {

public BurntException(int degrees) {
super("Potato is badly burnt by trying to boil it at " + degrees + " degrees!!");
public BurntException() {
super("Potato is badly burnt!!");
}

public BurntException(long bakeTime) {
super("Potato is badly burnt by baking for too long!! (" + bakeTime + "ms)");
public BurntException(String reason) {
super(reason);
}

}
4 changes: 2 additions & 2 deletions src/main/java/org/drtshock/Potato.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public boolean isPutIntoOven() throws OvenException, BurntException {
connection.connect();
int inOven = connection.getResponseCode();
long bakeTime = (System.currentTimeMillis() - begin);
if (bakeTime > 1100) throw new BurntException(bakeTime);
if (bakeTime > 1100) throw new BakedTooLongException(bakeTime);
return inOven == 200;
} catch (IOException ex) {
throw new OvenException(ex);
Expand Down Expand Up @@ -118,7 +118,7 @@ public boolean hasBeenBoiledInWater() throws BurntException {
if (waterDegrees < 70) {
return false;
} else if (waterDegrees > 130) {
throw new BurntException(waterDegrees);
throw new BoiledTooHotException(waterDegrees);
}
return true;
}
Expand Down