Commit 8ecfd170 authored by LI Qi's avatar LI Qi
Browse files

throw exception for invalid input

parent 4786b0b5
......@@ -9,8 +9,13 @@ public class Frame {
this.score = previousScore;
}
public void enterPoint(int point) {
public void enterPoint(int point) throws Exception {
if(point < 0 || point > 10)
throw new Exception("invalid point: [0, 10]");
if (firstLance == -1) this.firstLance = point;
else if (point + this.firstLance > 10)
throw new Exception("invalid point: [0, " + (10 - this.firstLance) + "]");
else this.secondLance = point;
this.score += point;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment