All Packages Class Hierarchy This Package Previous Next Index
Class tsadam.bowling.BowlingScore
java.lang.Object
|
+----tsadam.bowling.BowlingScore
- public class BowlingScore
- extends Object
- implements Cloneable
Keeps the bowling score for one line (one game by one player).
-
BowlingScore()
- Constructs a new bowling score line.
-
clone()
- Returns a copy of the bowling score line.
-
getBallMark(int)
- Gets the mark for the game ball.
-
getBallPinFall(int)
- Gets the pinfall for the game ball.
-
getFirstBall(int)
- Gets the pinfall for the first ball of a frame if it
was not a strike.
-
getFrameBall()
- Gets the current ball of the current frame.
-
getFrameNum()
- Gets current frame number.
-
getFrameScore(int)
- Gets the score at a frame.
-
getGameBall()
- Gets the current game ball.
-
getMark(int)
- Gets the mark of a frame.
-
init()
-
Initializes the bowling score line.
-
scoreBall(int)
- Scores a thrown ball.
-
scoreBallWithFramePinfall(int)
- Scores a thrown ball.
BowlingScore
public BowlingScore()
- Constructs a new bowling score line.
clone
public Object clone()
- Returns a copy of the bowling score line.
- Overrides:
- clone in class Object
getBallMark
public char getBallMark(int b)
- Gets the mark for the game ball.
- Parameters:
- b - the number of the game ball,
numbered from 0 (0 = 1st ball thrown in the game,
20 = 21st ball thrown in the game).
- Returns:
- ' ' = no mark - the ball was not the final ball of the frame;
'-' = the ball missed (did not make the spare);
'/' = the ball made a spare;
'x' = the ball made a strike
getBallPinFall
public int getBallPinFall(int b)
- Gets the pinfall for the game ball.
- Parameters:
- b - the number of the game ball,
numbered from 0 (0 = 1st ball thrown in the game,
20 = 21st ball thrown in the game).
- Returns:
- Number of pins knocked down with the ball.
-1 = the ball has not yet been thrown.
getFirstBall
public int getFirstBall(int f)
- Gets the pinfall for the first ball of a frame if it
was not a strike.
- Parameters:
- f - frame, numbered from 0
(0 = 1st frame). We count the balls thrown to
fill a 10th frame mark as separate frames (10 = "frame" for
filling a mark in the 10th, 11 = "frame" for filling
two strikes in the 10th).
- Returns:
- Pinfall; -1 = frame not yet played or strike.
getFrameBall
public int getFrameBall()
- Gets the current ball of the current frame.
Considers balls thrown to fill a mark in the 10th frame
as separate frames.
- Returns:
- 1 = first ball; 2 = second ball
getFrameNum
public int getFrameNum()
- Gets current frame number.
- Returns:
- frame, numbered from 0
(0 = 1st frame). We count the balls thrown to
fill a 10th frame mark as separate frames (10 = "frame" for
filling a mark in the 10th, 11 = "frame" for filling
two strikes in the 10th).
getFrameScore
public int getFrameScore(int f)
- Gets the score at a frame.
- Parameters:
- f - frame, numbered from 0
(0 = 1st frame).
- Returns:
- cumulative score at the frame.
-1 = not played, or not able to tally (a mark is pending).
getGameBall
public int getGameBall()
- Gets the current game ball.
- Returns:
- game ball, numbered from 0 (0 = 1st ball of game,
20 = 21st ball thrown in the game).
getMark
public char getMark(int f)
- Gets the mark of a frame.
- Parameters:
- f - frame, numbered from 0
(0 = 1st frame).
- Returns:
- ' ' = frame not yet played;
'-' = miss;
'/' = spare;
'x' = strike.
init
public void init()
- Initializes the bowling score line.
Can be used to start a new game using the same
bowling score object.
scoreBall
public int scoreBall(int pf)
- Scores a thrown ball.
- Parameters:
- pf - the pinfall for the ball.
- Returns:
- current frame (after ball is scored)
numbered from 0
(0 = 1st frame). We count the balls thrown to
fill a 10th frame mark as separate frames (10 = "frame" for
filling a mark in the 10th, 11 = "frame" for filling
two strikes in the 10th).
-1 = end of game.
scoreBallWithFramePinfall
public int scoreBallWithFramePinfall(int fpf)
- Scores a thrown ball.
- Parameters:
- fpf - the total pinfall in the frame after the
ball has been thrown. For example, if the first ball
has just been thrown and takes 5 pins, fpf = 5; if the
second ball has just been thrown and takes 3 pins after
the first ball had taken 6 pins, fpf = 9.
- Returns:
- current frame (after ball is scored)
numbered from 0
(0 = 1st frame). We count the balls thrown to
fill a 10th frame mark as separate frames (10 = "frame" for
filling a mark in the 10th, 11 = "frame" for filling
two strikes in the 10th).
-1 = end of game.
All Packages Class Hierarchy This Package Previous Next Index