All Packages Class Hierarchy This Package Previous Next Index
Class tsadam.bowling.BowlingSolitaire
java.lang.Object
|
+----tsadam.bowling.BowlingSolitaire
- public class BowlingSolitaire
- extends Object
One game of Bowling Solitaire (by Sid Sackson).
The game is for one player and one line
(ten frames) of bowling.
-
BowlingSolitaire()
- Constructs a game of Bowling Solitaire.
-
checkToPlayBallCard()
- Checks to see if it is legal to play a ball
card from the currently picked ball card pile.
-
checkToTogglePinPicked(int)
- Checks if it is legal to toggle the picked
status of a specific pin.
-
gameOver()
- Checks to see if the game is over.
-
getNumFallenPins()
- Gets the current number of fallen pins.
-
getNumPickedPins()
-
Gets number of pins currently picked.
-
getPlayedCards()
- Gets the array of the ranks played cards.
-
init()
- Initializes the game of Bowling Solitaire.
-
pickPile(int)
- Picks a ball card pile.
-
pileEmpty(int)
- Returns whether a specific ball card pile
is empty.
-
playBallCard()
- Plays the currently picked ball card.
-
setPinPicked(int)
- Sets the specified pin's status to "picked".
-
throwBall()
- Throws a ball.
-
togglePinPicked(int)
- Toggles the picked status of the
specified pin.
BowlingSolitaire
public BowlingSolitaire()
- Constructs a game of Bowling Solitaire.
The game contains a Bowling Score.
- See Also:
- BowlingScore
checkToPlayBallCard
public boolean checkToPlayBallCard()
- Checks to see if it is legal to play a ball
card from the currently picked ball card pile.
(Checks that all game rules are followed.)
- Returns:
- true = o.k. to play ball card;
false = not o.k. to play ball card
checkToTogglePinPicked
public boolean checkToTogglePinPicked(int p)
- Checks if it is legal to toggle the picked
status of a specific pin.
- Parameters:
- p - The pin to check, numbered from 0
(0 = head pin, 9 = ten pin).
- Returns:
- true = it's o.k. to toggle the picked status;
false = it's not o.k. to toggle the picked status.
gameOver
public boolean gameOver()
- Checks to see if the game is over.
- Returns:
- true = game is over;
false = game is not over.
getNumPickedPins
public int getNumPickedPins()
- Gets number of pins currently picked.
- Returns:
- Number of pins currently picked.
getNumFallenPins
public int getNumFallenPins()
- Gets the current number of fallen pins.
- Returns:
- number of fallen pins
getPlayedCards
public int[] getPlayedCards()
- Gets the array of the ranks played cards.
- Returns:
- array of the ranks of played cards,
indexed 0 to 19. The ranks are in the lowest
index positions, and the rest of the array
is filled with -1. For example, if 17
cards have been played, the ranks will be in
positions 0 through 16 and position 17 through
19 will contain -1.
init
public void init()
- Initializes the game of Bowling Solitaire.
This is the "play again" method.
pickPile
public boolean pickPile(int p)
- Picks a ball card pile.
- Parameters:
- p - pile to pick, numbered from 0.
- Returns:
- true = pile successfully picked;
false = pile not successfully picked.
pileEmpty
public boolean pileEmpty(int p)
- Returns whether a specific ball card pile
is empty.
- Parameters:
- p - ball card pile, numbered from 0.
- Returns:
- true = pile is empty;
false = pile is not empty.
playBallCard
public boolean playBallCard()
- Plays the currently picked ball card.
Checks first that it is legal to play
the ball card.
- Returns:
- true = ball card successfully played;
false = ball card not successfuelly played.
- See Also:
- checkToPlayBallCard
setPinPicked
public boolean setPinPicked(int p)
- Sets the specified pin's status to "picked".
First checks that it is legal to set the
pin's status to "picked".
- Parameters:
- p - pin, numbered from 0
(0 = head pin, 9 = ten pin).
- Returns:
- true = pin's status succesfully set to "picked";
false = * true = pin's status not succesfully
set to "picked".
throwBall
public int throwBall()
- Throws a ball.
- Returns:
- current frame after ball has been
thrown, 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.
togglePinPicked
public boolean togglePinPicked(int p)
- Toggles the picked status of the
specified pin.
- Parameters:
- p - pin, numbered from 0
(0 = head pin, 9 = ten pin).
- Returns:
- true = pin's picked status successfully toggled.
false = pin's picked status not successfully toggled.
All Packages Class Hierarchy This Package Previous Next Index