Class Board

java.lang.Object
  |
  +--PrintSuperClass
        |
        +--Board
Direct Known Subclasses:
Ships

public class Board
extends PrintSuperClass

Creates Board - Note board Matrix is public

               
Normal Board Access Uses...
public boolean set( char c, Coordinates p ) 
set location p to c - returns false if unable to set contents

public char get( Coordinates c )  returns char at location c

Child class Ships clears board between games;

Board Declares Global Constants
MAXROWS, MAXCOLSEMPTYCHAR, HITCHAR, MISSCHAR

Poosible Future Upgrade: Board extends Coordinates, Coordinate is current guess


Field Summary
 char[][] board
          board represents, the guessing board or your defensive ships board
static char EMPTYCHAR
          Global constant represent the board character for an empty coordinate Initially the entire guessing board is empty
static char HITCHAR
          Global constant represent the board character for a hit coordinate
static int MAXCOLS
          Global constant number of columns on each board
static int MAXROWS
          Global constant number of rows on each board a Coordinate is row, column
static char MISSCHAR
          Global constant represent the board character for a missed coordinate
 
Constructor Summary
Board()
          creates the board matrix and sets all coordinates to EMPTYCHAR
 
Method Summary
 void clear()
           
 void copy(Board b)
           
 char get(Coordinates c)
           
 char get(int r, int c)
           
static void main(java.lang.String[] args)
          used for testing board and print method
 void print(java.io.PrintWriter pw)
          prints the entire board, for subclass ship prints the ship character codes for a guessing board will print EMPTYCHAR, MISSCHAR and HITCHAR ar each coordinate
 void println(java.io.PrintWriter pw)
           
 boolean set(char c, Coordinates p)
          sets the coordinate p on board to the char c
 
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

MAXROWS

public static final int MAXROWS
Global constant number of rows on each board a Coordinate is row, column

MAXCOLS

public static final int MAXCOLS
Global constant number of columns on each board

EMPTYCHAR

public static final char EMPTYCHAR
Global constant represent the board character for an empty coordinate Initially the entire guessing board is empty

HITCHAR

public static final char HITCHAR
Global constant represent the board character for a hit coordinate

MISSCHAR

public static final char MISSCHAR
Global constant represent the board character for a missed coordinate

board

public char[][] board
board represents, the guessing board or your defensive ships board
Constructor Detail

Board

public Board()
creates the board matrix and sets all coordinates to EMPTYCHAR
Method Detail

set

public boolean set(char c,
                   Coordinates p)
sets the coordinate p on board to the char c
Returns:
true if p is a legal coordinate

get

public char get(Coordinates c)
Returns:
the board character at coordinate c

get

public char get(int r,
                int c)
Returns:
the board character at location r, c

copy

public void copy(Board b)
Parameters:
b - board is copied into the calling object

clear

public void clear()

print

public void print(java.io.PrintWriter pw)
prints the entire board, for subclass ship prints the ship character codes for a guessing board will print EMPTYCHAR, MISSCHAR and HITCHAR ar each coordinate
Overrides:
print in class PrintSuperClass

println

public void println(java.io.PrintWriter pw)
Overrides:
println in class PrintSuperClass

main

public static void main(java.lang.String[] args)
used for testing board and print method