Class Player

java.lang.Object
  extended by Player

public class Player
extends java.lang.Object


Field Summary
private  Ship Battleship1
           
private  Ship Battleship2
           
private  Ship Carrier1
           
private  Ship Carrier2
           
private  Ship Destroyer1
           
private  Ship Destroyer2
           
private  Turn hit
           
private  int mode
           
private  Ship PTBoat1
           
private  Ship PTBoat2
           
private  Ship Submarine1
           
private  Ship Submarine2
           
 
Constructor Summary
Player(int who, Grid gridO)
          The Player class is sued to setup the ships for each player,also is sued to shoot and attack other players ships and as well is used to detract the ships health
 
Method Summary
 int aiAttack(Grid gridO)
          Used to incorporate the Artifical Intelligence attack, basically the brain behind the operation
 int GameOver(int player)
          Used to determine when the game is over or not
 int getMode()
          Used to get the attack mode of the AI
 int getShipHp(int type)
          used to return the HP of the ship determined by the type of ship passed in
 int guiSetupShips(Grid gridO, int play, int type, int x, int y, int o)
          Used to setup the ships for the gui front end
 void setMode(int m)
          Used to set the attack mode of the AI
 int shipID(java.lang.String BoatHit)
          Used to ID the ship that was hit and to deduct its headpoints
 int shipID2(java.lang.String BoatHit)
          Used to ID the ship that was hit and to deduct its headpoints
 int shootShips(int player, Grid gridO, int height, int length, int row, int col)
          Used to fire at ships from variables being passed from the main game class
 int showShip(int shipT)
          Used to show the ship status of the computers ships
 int showShip2(int shipT)
          Used to show the ship status of the computers ships
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Carrier1

private Ship Carrier1

Carrier2

private Ship Carrier2

Battleship1

private Ship Battleship1

Battleship2

private Ship Battleship2

Submarine1

private Ship Submarine1

Submarine2

private Ship Submarine2

Destroyer1

private Ship Destroyer1

Destroyer2

private Ship Destroyer2

PTBoat1

private Ship PTBoat1

PTBoat2

private Ship PTBoat2

hit

private Turn hit

mode

private int mode
Constructor Detail

Player

public Player(int who,
              Grid gridO)
The Player class is sued to setup the ships for each player,also is sued to shoot and attack other players ships and as well is used to detract the ships health

Parameters:
who - - determines the player coming into the constructor
gridO - - Determines which player grid to use to setup ships
Method Detail

shootShips

public int shootShips(int player,
                      Grid gridO,
                      int height,
                      int length,
                      int row,
                      int col)
Used to fire at ships from variables being passed from the main game class

Parameters:
player - - This is used to determine which player is shooting
gridO - - This is used to determine which grid to shot on
height - - this is the height of the grid
length - - this is the length of the grid
row - - this is the row coordinate to shoot at
col - - this is the column coordinate to shoot at
Returns:
true if a ship was hit or false if there was a miss

GameOver

public int GameOver(int player)
Used to determine when the game is over or not

Parameters:
player - - Which player to check for
Returns:
returns true if the opponents ships are sunk

aiAttack

public int aiAttack(Grid gridO)
Used to incorporate the Artifical Intelligence attack, basically the brain behind the operation

Parameters:
gridO - - The grid used to attack
Returns:
true if there was a hit or -1 for a miss

shipID

public int shipID(java.lang.String BoatHit)
Used to ID the ship that was hit and to deduct its headpoints

Parameters:
BoatHit - - Used to identify the boat that was hit
Returns:
returns 1 for successfuly identifying and subtracting hp points and a 2 for a sunken ship

shipID2

public int shipID2(java.lang.String BoatHit)
Used to ID the ship that was hit and to deduct its headpoints

Parameters:
BoatHit - - Used to identify the boat that was hit
Returns:
returns 1 for successfuly identifying and subtracting hp points and a 2 for a sunken ship

setMode

public void setMode(int m)
Used to set the attack mode of the AI

Parameters:
m - - Used to set the attack mode, 0 for off and 1 for on

getMode

public int getMode()
Used to get the attack mode of the AI

Returns:
returns the attack modes current state

showShip

public int showShip(int shipT)
Used to show the ship status of the computers ships

Parameters:
shipT - - The ship type being checked on
Returns:
returns true if the ship is not active and sunk

showShip2

public int showShip2(int shipT)
Used to show the ship status of the computers ships

Parameters:
shipT - - The ship type being checked on
Returns:
returns true if the ship is not active and sunk

guiSetupShips

public int guiSetupShips(Grid gridO,
                         int play,
                         int type,
                         int x,
                         int y,
                         int o)
Used to setup the ships for the gui front end

Parameters:
gridO - - The grid to set the ships on
type - - the type of ship that needs to be setup
x - - the row coordinate for the starting spot
y - - the column coordinate for the starting spot
o - - the orientation for the ship, vertical or horizontal
Returns:
returns true if the ship is placed sucessfully, 2 if off the grid and 3 if it comes in conflict with another ship

getShipHp

public int getShipHp(int type)
used to return the HP of the ship determined by the type of ship passed in

Parameters:
type - - the tye of ship that needs to be checked
Returns:
returns the ships health