Class Team

java.lang.Object
  extended by Team

public class Team
extends Object

This class represents a team object. Its instance variables represent the attributes of a team. Its methods represent things the team can do.

Version:
20050603
Author:
Colin Moore, Peter Gadfort

Constructor Summary
Team(String name, Color color, Dimension size, Dimension boardSize, boolean type)
          Constructor to initialize the variables
 
Method Summary
 void autoMove(Dimension boardSize, Puck puck)
          The AI code for the computer team.
 void center(Dimension boardSize)
          Centers the paddle
 void checkCollision(Puck puck)
          Checks for a collision between the strikers and the puck.
 boolean checkScore(Dimension boardSize, Puck puck)
          Checks for a score on the teams goal.
 void draw(Graphics g)
          Draws the paddle on the input screen
 Color getColor()
          Returns the color of the team
 int getX()
          Returns the current x coordinate of the paddle
 int getY()
          Returns the current y coordinate of the paddle
 void increaseScore()
          Increases the score by one
 void moveLeft(Dimension boardSize)
          Moves the paddle to the left
 void moveLeft(Dimension boardSize, int length)
          Moves the paddle to the left by the distance specified
 void moveRight(Dimension boardSize)
          Moves the paddle to the right
 void moveRight(Dimension boardSize, int length)
          Moves the paddle to the right by the distance specified
 void resize(Dimension boardSize, boolean type)
          Resizes the goal and moves the paddle to the appropriate locations
 void setGoal(Dimension boardSize, boolean type)
          Sets the location of the goal
 void setPosition(Dimension boardSize, int x, int y)
          Sets the position of the paddle to the coordinates specified
 void setX(Dimension boardSize, int x)
          Sets the x coordinate of the paddle
 void setY(Dimension boardSize, int y)
          Sets the y coordinate of the paddle
 String toString()
          Returns a string with the team name and their current score
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Team

public Team(String name,
            Color color,
            Dimension size,
            Dimension boardSize,
            boolean type)
Constructor to initialize the variables

Parameters:
name - Name of the team
color - The color to set the team
size - The size to set the paddle
boardSize - The dimensions of the board the puck is on
type - Declares if the team is automated or not
Method Detail

autoMove

public void autoMove(Dimension boardSize,
                     Puck puck)
The AI code for the computer team.

Parameters:
boardSize - The dimensions of the board the paddle is on
puck - The puck that is on the board

center

public void center(Dimension boardSize)
Centers the paddle

Parameters:
boardSize - The dimensions of the board the paddle is on

checkCollision

public void checkCollision(Puck puck)
Checks for a collision between the strikers and the puck. Makes the puck bounce if collision exists.

Parameters:
puck - The puck that is on the board

checkScore

public boolean checkScore(Dimension boardSize,
                          Puck puck)
Checks for a score on the teams goal.

Parameters:
boardSize - The dimensions of the board the paddle is on
puck - The puck that is on the board
Returns:
True if a score occured, otherwise false

draw

public void draw(Graphics g)
Draws the paddle on the input screen

Parameters:
g - The input screen on which the paddle will be drawn

getColor

public Color getColor()
Returns the color of the team

Returns:
Color of the team

getX

public int getX()
Returns the current x coordinate of the paddle

Returns:
The x coordinate of the paddle

getY

public int getY()
Returns the current y coordinate of the paddle

Returns:
The y coordinate of the paddle

increaseScore

public void increaseScore()
Increases the score by one


moveLeft

public void moveLeft(Dimension boardSize)
Moves the paddle to the left

Parameters:
boardSize - The dimensions of the board the paddle is on

moveLeft

public void moveLeft(Dimension boardSize,
                     int length)
Moves the paddle to the left by the distance specified

Parameters:
boardSize - The dimensions of the board the paddle is on
length - The distance the paddle must move

moveRight

public void moveRight(Dimension boardSize)
Moves the paddle to the right

Parameters:
boardSize - The dimensions of the board the paddle is on

moveRight

public void moveRight(Dimension boardSize,
                      int length)
Moves the paddle to the right by the distance specified

Parameters:
boardSize - The dimensions of the board the paddle is on
length - The distance the paddle must move

resize

public void resize(Dimension boardSize,
                   boolean type)
Resizes the goal and moves the paddle to the appropriate locations

Parameters:
boardSize - The dimensions of the board the puck is on
type - Declares if the team is automated or not

setGoal

public void setGoal(Dimension boardSize,
                    boolean type)
Sets the location of the goal

Parameters:
boardSize - The dimensions of the board the puck is on
type - Declares if the team is automated or not

setPosition

public void setPosition(Dimension boardSize,
                        int x,
                        int y)
Sets the position of the paddle to the coordinates specified

Parameters:
boardSize - The dimensions of the board the paddle is on
x - The x coordinate of the paddle
y - The y coordinate of the paddle

setX

public void setX(Dimension boardSize,
                 int x)
Sets the x coordinate of the paddle

Parameters:
boardSize - The dimensions of the board the paddle is on
x - The new x coordinate of the paddle

setY

public void setY(Dimension boardSize,
                 int y)
Sets the y coordinate of the paddle

Parameters:
boardSize - The dimensions of the board the paddle is on
y - The new y coordinate of the paddle

toString

public String toString()
Returns a string with the team name and their current score

Overrides:
toString in class Object
Returns:
String with the team name and score