Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
LI Qi
Bowling
Commits
8ecfd170
Commit
8ecfd170
authored
Feb 12, 2016
by
LI Qi
Browse files
throw exception for invalid input
parent
4786b0b5
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/game/Frame.java
View file @
8ecfd170
...
@@ -9,8 +9,13 @@ public class Frame {
...
@@ -9,8 +9,13 @@ public class Frame {
this
.
score
=
previousScore
;
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
;
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
;
else
this
.
secondLance
=
point
;
this
.
score
+=
point
;
this
.
score
+=
point
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment