Index
All Classes and Interfaces|All Packages|Constant Field Values
A
- act() - Method in class student.micro.battleship.Game
-
Plays one turn in the current game.
- addedToWorld(World) - Method in class student.micro.battleship.ShipPiece
- afterFiring() - Method in enum student.micro.battleship.CellStatus
-
Return the new cell status that would be obtained by firing on a cell of this cell status (e.g., EMPTY returns MISS and SHIP returns HIT).
- applyMove(Move) - Method in class student.micro.battleship.TestableBoard
-
Update the board as if its owner had played the specified move (of any kind).
- areAllShipsSunk() - Method in class student.micro.battleship.Board
-
Determine if all ships on this board have been sunk.
B
- BATTLESHIP - Enum constant in enum student.micro.battleship.ShipType
-
Represents a Battleship, which is 4 units long.
- BattleshipStrategy - Interface in student.micro.battleship
-
An implementation of this interface represents a "strategy" or a computer A.I.
- BattleshipTestBase - Class in student.micro.battleship
-
Base class for battleship reference tests.
- BattleshipTestBase() - Constructor for class student.micro.battleship.BattleshipTestBase
-
Creates a new BattleshipTestBase test object.
- Board - Class in student.micro.battleship
-
Represents one player's board in the classic board game "Battleship".
- Board() - Constructor for class student.micro.battleship.Board
-
Create a new, empty board.
- BruteforceStrategy - Class in student.micro.battleship
-
A strategy for the classic board game "Battleship" that methodically plods along, firing at cells in order.
- BruteforceStrategy() - Constructor for class student.micro.battleship.BruteforceStrategy
-
Create a new strategy object.
C
- callNextShot(GameState) - Method in interface student.micro.battleship.BattleshipStrategy
-
The main "play" method for this strategy--called when it is this player's turn to call out a shot on the opponent's board to try to hit one of the opponent's ships.
- callNextShot(GameState) - Method in class student.micro.battleship.BruteforceStrategy
-
The main "play" method for this strategy--called when it is this player's turn to call out a shot on the opponent's board to try to hit one of the opponent's ships.
- callNextShot(GameState) - Method in class student.micro.battleship.RandomStrategy
-
The main "play" method for this strategy--called when it is this player's turn to call out a shot on the opponent's board to try to hit one of the opponent's ships.
- CallShotMove - Class in student.micro.battleship
-
Represents a "call out a shot" (or make a shot) move in the game "Battleship".
- CallShotMove(int, int) - Constructor for class student.micro.battleship.CallShotMove
-
Creates a new move.
- canFireAt(int, int) - Method in class student.micro.battleship.Board
-
Determine if firing at the specified location would be a legal move at this Position in the game (i.e., if it has not been fired on before).
- canPlayDeviously() - Method in interface student.micro.battleship.BattleshipStrategy
-
In some games, strategies that wish to may play "deviously", meaning they will reposition their ships when allowed.
- canPlayDeviously() - Method in class student.micro.battleship.BruteforceStrategy
-
In some games, strategies that wish to may play "deviously", meaning they will reposition their ships when allowed.
- canPlayDeviously() - Method in class student.micro.battleship.RandomStrategy
-
In some games, strategies that wish to may play "deviously", meaning they will reposition their ships when allowed.
- CARRIER - Enum constant in enum student.micro.battleship.ShipType
-
Represents an Aircraft Carrier, which is 5 units long.
- CellStatus - Enum in student.micro.battleship
-
Represents a move that sets the positions of all the player's ships on his or her board in the game "Battleship".
- containsShip() - Method in enum student.micro.battleship.CellStatus
-
Determine if this cell status indicates that the cell is occupied by a ship.
- createMyStrategy() - Method in class student.micro.battleship.Game
-
Create a strategy object representing your player strategy.
- createOpponentsStrategy() - Method in class student.micro.battleship.Game
-
Create a strategy object representing your opponent's strategy.
D
- DESTROYER - Enum constant in enum student.micro.battleship.ShipType
-
Represents a Destroyer, which is 3 units long.
E
- EMPTY - Enum constant in enum student.micro.battleship.CellStatus
-
Represents an empty cell that has not been fired on.
- equals(Object) - Method in class student.micro.battleship.Board
- equals(Object) - Method in class student.micro.battleship.CallShotMove
- equals(Object) - Method in class student.micro.battleship.Position
-
Compare this position object to another to determine if they represent the same (x, y) location.
- equals(Object) - Method in class student.micro.battleship.Ship
- equals(Object) - Method in class student.micro.battleship.ShipPlacementMove
F
- fireAt(int, int) - Method in class student.micro.battleship.TestableBoard
-
Update the board as if a shot were fired at the specified position.
- firedOn() - Method in enum student.micro.battleship.CellStatus
-
Determine if this cell status indicates that the cell has been fired upon by the opponent.
- firePattern(String...) - Method in class student.micro.battleship.TestableBoard
-
Fire at a series of cells, using the layout contained in the series of parameter strings.
G
- Game - Class in student.micro.battleship
-
The playing area of a "Battleship" game, consisting of two boards for the two players.
- Game() - Constructor for class student.micro.battleship.Game
-
Create a new game.
- GameState - Class in student.micro.battleship
-
Represents the state of a game of "Battleship", including both players' boards.
- GameState() - Constructor for class student.micro.battleship.GameState
-
Create a new game state, with two empty boards.
- getHitsSoFar() - Method in class student.micro.battleship.Ship
-
How many times has this ship been hit so far?
- getLastAttackX() - Method in class student.micro.battleship.Board
-
Get the x-coordinate of the position that was fired on in the previous turn.
- getLastAttackY() - Method in class student.micro.battleship.Board
-
Get the y-coordinate of the position that was fired on in the previous turn.
- getLastShipSunk() - Method in class student.micro.battleship.Board
-
Get the most recent ship that has been sunk on this board (no matter how long ago the most recent sinking occurred).
- getLength() - Method in enum student.micro.battleship.ShipType
-
Get the length of this type of ship.
- getMyBoard() - Method in class student.micro.battleship.GameState
-
Get my board from the game state.
- getMyBoard() - Method in class student.micro.battleship.TestableGameState
-
Get my board from the game state.
- getName() - Method in interface student.micro.battleship.BattleshipStrategy
-
Gets the name of this player/strategy.
- getName() - Method in class student.micro.battleship.BruteforceStrategy
-
Gets the name of this player/strategy.
- getName() - Method in class student.micro.battleship.RandomStrategy
-
Gets the name of this player/strategy.
- getOpponentsBoard() - Method in class student.micro.battleship.GameState
-
Get my opponent's board from the game state.
- getOpponentsBoard() - Method in class student.micro.battleship.TestableGameState
-
Get my opponent's board from the game state.
- getRound() - Method in class student.micro.battleship.GameState
-
Get this game's current round number (the number of shots fired by both players so far).
- getShip(ShipType) - Method in class student.micro.battleship.ShipPlacementMove
-
Get the specified ship associated with this placement move.
- getShips() - Method in class student.micro.battleship.ShipPlacementMove
-
Get list of the specified ships associated with this placement move.
- getShipType() - Method in class student.micro.battleship.Ship
-
Get the type of this ship.
- getStatusAt(int, int) - Method in class student.micro.battleship.Board
-
Get the status of a single cell on this board.
- getSunkenShips() - Method in class student.micro.battleship.Board
-
Get a list of all ships sunk so far on this board.
- getX() - Method in class student.micro.battleship.CallShotMove
-
Get the x-coordinate of the position associated with this shot.
- getX() - Method in class student.micro.battleship.Position
-
Get the x-coordinate value for this position.
- getX() - Method in class student.micro.battleship.Ship
-
Get the x-coordinate of this ship's bow (which is always the north/upper end of a vertically oriented ship, or the west/left end of a horizontally oriented ship).
- getY() - Method in class student.micro.battleship.CallShotMove
-
Get the y-coordinate of the position associated with this shot.
- getY() - Method in class student.micro.battleship.Position
-
Get the y-coordinate value for this position.
- getY() - Method in class student.micro.battleship.Ship
-
Get the y-coordinate of this ship's bow (which is always the north/upper end of a vertically oriented ship, or the west/left end of a horizontally oriented ship).
H
- hashCode() - Method in class student.micro.battleship.Board
- hashCode() - Method in class student.micro.battleship.CallShotMove
- hashCode() - Method in class student.micro.battleship.Ship
- hashCode() - Method in class student.micro.battleship.ShipPlacementMove
- HEIGHT - Static variable in class student.micro.battleship.Board
-
The height of a board (10 cells).
- hideShips() - Method in class student.micro.battleship.Board
-
By default, ships are "visible" by calling
getStatusAt()
on cells that have not been fired on. - hideShips() - Method in enum student.micro.battleship.CellStatus
-
Return the new cell status that would be obtained by firing on a cell of this cell status (e.g., EMPTY returns MISS and SHIP returns HIT).
- Hit - Class in student.micro.battleship
-
Represents a red "hit" peg in the game "Battleship", so it can be shown on the screen.
- Hit() - Constructor for class student.micro.battleship.Hit
-
Create a new Hit peg.
- HIT - Enum constant in enum student.micro.battleship.CellStatus
-
Represents a cell that has been fired on and that is occupied by (part of) a ship (a hit).
I
- isOrientedHorizontally() - Method in class student.micro.battleship.Ship
-
Get whether this ship is oriented horizontally (left-right) or vertically (up-down) on the board.
- isSunk() - Method in class student.micro.battleship.Ship
-
Determine whether this ship has been sunk in the game.
- isValid() - Method in class student.micro.battleship.ShipPlacementMove
-
Determine whether this move is a valid one, according to the rules of the game.
L
- lastAttackSunkAShip() - Method in class student.micro.battleship.Board
-
Determine if the last cell that was fired on caused a ship to be sunk.
M
- Miss - Class in student.micro.battleship
-
Represents a white "miss" peg in the game "Battleship", so it can be shown on the screen.
- Miss() - Constructor for class student.micro.battleship.Miss
-
Create a new Miss peg.
- MISS - Enum constant in enum student.micro.battleship.CellStatus
-
Represents an empty cell that has been fired on (a miss).
- Move - Class in student.micro.battleship
-
A base class that represents any kind of "move" that can be made by a player for the classic board game "Battleship".
- Move() - Constructor for class student.micro.battleship.Move
N
- newGame() - Method in interface student.micro.battleship.BattleshipStrategy
-
Called to initialize (or re-initialize) this strategy to play a new game.
- newGame() - Method in class student.micro.battleship.BruteforceStrategy
-
Called to initialize (or re-initialize) this strategy to play a new game.
- newGame() - Method in class student.micro.battleship.RandomStrategy
-
Called to initialize (or re-initialize) this strategy to play a new game.
O
- occupies(int, int) - Method in class student.micro.battleship.Ship
-
Determine if this ship occupies the specified location.
P
- PATROL - Enum constant in enum student.micro.battleship.ShipType
-
Represents a Patrol Boat, which is 2 units long.
- placeShip(ShipType, int, int, boolean) - Method in class student.micro.battleship.ShipPlacementMove
-
Place the player's ship of the specified type at the given position with the specified orientation.
- placeShip(ShipType, int, int, boolean) - Method in class student.micro.battleship.TestableBoard
-
Place the player's ship of the specified type at the given position with the specified orientation.
- placeShips(String...) - Method in class student.micro.battleship.TestableBoard
-
Place the player's ships all on the board using a "textual" grid layout contained in the provided series of strings, one per row.
- placeShips(GameState) - Method in interface student.micro.battleship.BattleshipStrategy
-
Called when this strategy can place its ships on the board, so that it can indicate where it wants its ships to go (typically at the start of a game).
- placeShips(GameState) - Method in class student.micro.battleship.BruteforceStrategy
-
Called when this strategy can place its ships on the board, so that it can indicate where it wants its ships to go (typically at the start of a game).
- placeShips(GameState) - Method in class student.micro.battleship.RandomStrategy
-
Called when this strategy can place its ships on the board, so that it can indicate where it wants its ships to go (typically at the start of a game).
- playDeviousGame() - Method in class student.micro.battleship.Game
-
Play one game between my strategy and the opponent's strategy, indicating which strategy won at the end.
- playNDeviousGames(int) - Method in class student.micro.battleship.Game
-
Play a series of N games between my strategy and the opponent's strategy, indicating at the end how many of the games each strategy won.
- playNStandardGames(int) - Method in class student.micro.battleship.Game
-
Play a series of N games between my strategy and the opponent's strategy, indicating at the end how many of the games each strategy won.
- playStandardGame() - Method in class student.micro.battleship.Game
-
Play one game between my strategy and the opponent's strategy, indicating which strategy won at the end.
- Position - Class in student.micro.battleship
-
Represents an (x, y) position.
- Position(int, int) - Constructor for class student.micro.battleship.Position
-
Create a new (x, y) position.
R
- RandomStrategy - Class in student.micro.battleship
-
A strategy for the classic board game "Battleship" that methodically plods along, firing at cells in order.
- RandomStrategy() - Constructor for class student.micro.battleship.RandomStrategy
-
Create a new strategy object.
S
- setUp() - Method in class student.micro.battleship.BattleshipTestBase
-
Sets up the test fixture.
- Ship - Class in student.micro.battleship
-
Represents a single ship in a player's fleet in the classic board game "Battleship".
- Ship(ShipType, int, int, boolean) - Constructor for class student.micro.battleship.Ship
-
Create a brand new ship (that has never been hit).
- SHIP - Enum constant in enum student.micro.battleship.CellStatus
-
Represents a cell that is occupied by (part of) a ship.
- ShipPiece - Class in student.micro.battleship
-
Represents a ship piece in the game "Battleship", so it can be shown on the screen.
- ShipPiece(ShipType, int, int, boolean) - Constructor for class student.micro.battleship.ShipPiece
-
Create a new Ship piece.
- ShipPlacementMove - Class in student.micro.battleship
-
Represents a move that sets the positions of all the player's ships on his or her board in the game "Battleship".
- ShipPlacementMove(GameState) - Constructor for class student.micro.battleship.ShipPlacementMove
-
Creates a new move.
- ShipPlacementMove(GameState, String...) - Constructor for class student.micro.battleship.ShipPlacementMove
-
Creates a new move from a series of strings representing ship positions, one string per row.
- ShipType - Enum in student.micro.battleship
-
An enumeration representing the five types of ships in a player's fleet in the game "Battleship".
- showShips() - Method in class student.micro.battleship.TestableBoard
-
By default, an opponent's ships are hidden (see
Board.hideShips()
), but this method will reveal the positions of any ships occupying cells that have not yet been fired on for testing purposes. - student.micro.battleship - package student.micro.battleship
- SUBMARINE - Enum constant in enum student.micro.battleship.ShipType
-
Represents a Submarine, which is 3 units long.
T
- TestableBoard - Class in student.micro.battleship
-
A special subclass of
Board
that adds extra features useful in writing test cases. - TestableBoard() - Constructor for class student.micro.battleship.TestableBoard
-
Create a new, empty board.
- TestableGameState - Class in student.micro.battleship
-
A special subclass of
GameState
that adds extra features useful in writing test cases. - TestableGameState() - Constructor for class student.micro.battleship.TestableGameState
-
Create a new game state, with two empty boards.
- toString() - Method in class student.micro.battleship.Board
-
Generate a human-readable representation of this board, showing all of the hits (as X's) and misses (as O's).
- toString() - Method in class student.micro.battleship.CallShotMove
- toString() - Method in class student.micro.battleship.GameState
- toString() - Method in class student.micro.battleship.Position
-
Generate a human-readable representation of this position as "(x, y)".
- toString() - Method in class student.micro.battleship.Ship
- toString() - Method in class student.micro.battleship.ShipPlacementMove
V
- valueOf(int) - Static method in enum student.micro.battleship.ShipType
-
Get the ship value corresponding to the specified ordinal value.
- valueOf(String) - Static method in enum student.micro.battleship.CellStatus
-
Returns the enum constant of this type with the specified name.
- valueOf(String) - Static method in enum student.micro.battleship.ShipType
-
Returns the enum constant of this type with the specified name.
- values() - Static method in enum student.micro.battleship.CellStatus
-
Returns an array containing the constants of this enum type, in the order they are declared.
- values() - Static method in enum student.micro.battleship.ShipType
-
Returns an array containing the constants of this enum type, in the order they are declared.
W
A B C D E F G H I L M N O P R S T V WAll Classes and Interfaces|All Packages|Constant Field Values