|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--PrintSuperClass
|
+--Board
|
+--Ships
Used to create and maintain ships at sea. Extends Board Maintains a board with ships and current ship status
Defines Constant MAXSHIPS Each Ship has Five Fields String name, char code, int size, boolean sunk, boolean placed
Note system has 6 boards per games Each player has public access to his defensive and offensive board Board with ships player is attacking is kept private
Player's makeMove with message IDPlaceShips will use a placeShips
| Field Summary | |
static char[] |
code
Character array each code represent unique ship identifier |
static char |
DOWN
|
static java.lang.String[] |
exceptions
Defines the Three exceptions thrown by placeShips method |
static char |
LEFT
|
static int |
MAXSHIPS
Global constants defines The number of Ships |
static java.lang.String[] |
name
String array representing the name of each ship |
static char |
RIGHT
|
static int[] |
size
int array representing the size of each ship |
static char |
UP
Four Codes for Ship Direction |
| Fields inherited from class Board |
board, EMPTYCHAR, HITCHAR, MAXCOLS, MAXROWS, MISSCHAR |
| Constructor Summary | |
Ships()
Ship constructor creates sunk and place array, constructor board is called first |
|
| Method Summary | |
boolean |
allShipsPlaced()
Used by battleship Simulator to verify correct placement of all ships |
boolean |
allShipsSunk()
Used by battleship Simulator |
boolean |
checkSunk(Coordinates c)
Used by BattleShip Simulator |
void |
clear()
resets place and sunk arrays to false and clear board |
void |
copy(Ships s)
Used by battleShip simulator to make a new copy of a ship object |
int |
findShip(char c)
|
boolean |
placeShips(int id,
Coordinates f,
char direction)
|
boolean |
placeShips(int id,
Coordinates f,
Coordinates s)
Must be used by all Player's to place each ship individual |
void |
print(java.io.PrintWriter pw)
Prints out current ship statistics index, code, name, placed and sunk and calls @see board#print |
void |
println(java.io.PrintWriter pw)
|
void |
setSunk(int index)
called by BattleShip simulator when the ship corresponding to to the specified index is sunk |
| Methods inherited from class Board |
copy, get, get, main, set |
| Methods inherited from class PrintSuperClass |
print, print, print, println, println, println |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int MAXSHIPS
public static final char UP
public static final char DOWN
public static final char LEFT
public static final char RIGHT
public static final java.lang.String[] name
public static final char[] code
public static final int[] size
public static final java.lang.String[] exceptions
| Constructor Detail |
public Ships()
| Method Detail |
public void setSunk(int index)
public void copy(Ships s)
public void clear()
clear in class Boardpublic boolean allShipsSunk()
public boolean allShipsPlaced()
public int findShip(char c)
c - is the character code that uniquely identifies the shippublic boolean checkSunk(Coordinates c)
c - is Coordinates representing location containing a hit shippublic void print(java.io.PrintWriter pw)
print in class Boardpublic void println(java.io.PrintWriter pw)
println in class Board
public boolean placeShips(int id,
Coordinates f,
char direction)
throws java.lang.Exception
id - is Ship id to be placesf - is front coordinate of shipdirection, - is direction of ship placement, UP, DOWN, LEFT, RIGHT
public boolean placeShips(int id,
Coordinates f,
Coordinates s)
throws java.lang.Exception
id - represent the ship index IDf - represents the starting front coordinate of the ships - represents the stern rear coordinate of shipwith - messages NoSuchShip, shipExists, OutOfBounds,
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||