Add bakeTime to BurntException
This commit is contained in:
parent
b0b434b614
commit
59e7da2dbb
|
@ -9,8 +9,8 @@ public class BurntException extends Exception {
|
||||||
super("Potato is badly burnt by trying to boil it at " + degrees + " degrees!!");
|
super("Potato is badly burnt by trying to boil it at " + degrees + " degrees!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public BurntException() {
|
public BurntException(long bakeTime) {
|
||||||
super("Potato is badly burnt by baking for too long!");
|
super("Potato is badly burnt by baking for too long!! (" + bakeTime + "ms)");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class Potato implements Tuber {
|
||||||
connection.connect();
|
connection.connect();
|
||||||
int inOven = connection.getResponseCode();
|
int inOven = connection.getResponseCode();
|
||||||
long bakeTime = (System.currentTimeMillis() - begin);
|
long bakeTime = (System.currentTimeMillis() - begin);
|
||||||
if (bakeTime > 1100) throw new BurntException();
|
if (bakeTime > 1100) throw new BurntException(bakeTime);
|
||||||
return inOven == 200;
|
return inOven == 200;
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new OvenException(ex);
|
throw new OvenException(ex);
|
||||||
|
|
Loading…
Reference in New Issue