gizmoball.board
Class Ball

java.lang.Object
  extended by gizmoball.board.Gizmo
      extended by gizmoball.board.Ball

public class Ball
extends Gizmo

This class represents a ball gizmo that extends the abstract Gizmo class. A ball has a velocity that can be changed, and the ball can move around. A ball can be a "ghost ball" which then does not collide with other balls.

Author:
Michal Wexler

Field Summary
 
Fields inherited from class gizmoball.board.Gizmo
color, connections, name, reverseConnections
 
Constructor Summary
Ball(java.lang.String name, java.awt.Color color, double radius, Vect initialLocation, Vect velocity, boolean inAbsorber, boolean ghostBall)
          constructs a Ball object.
 
Method Summary
 void action()
          a ball does not have an action.
 void changeCenter(Vect loc)
          moves the center of the ball to a new location.
 double getMass()
          returns the mass of the ball.
 Circle09 getShape()
          returns the shape of the ball.
 Vect getVelocity()
          returns the velocity of the ball.
 boolean isGhostBall()
          checks if the ball is a ghost ball.
 boolean isInAbsorber()
          returns if the ball is in an absorber or not.
 void setInAbsorber(boolean bool)
          sets the state of whether the ball is in an absorber.
 void setVelocity(Vect v)
          sets the velocity of the ball.
 
Methods inherited from class gizmoball.board.Gizmo
getColor, getName, getTriggeredGizmos, getTriggeringGizmos, setColor, triggerConnections
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ball

public Ball(java.lang.String name,
            java.awt.Color color,
            double radius,
            Vect initialLocation,
            Vect velocity,
            boolean inAbsorber,
            boolean ghostBall)
constructs a Ball object.

Parameters:
name - the name of the ball
color - the color of the ball
radius - the radius of the ball
initialLocation - the initial location of the ball
velocity - the initial velocity of the ball
inAbsorber - a boolean that specifies whether the ball is absorbed by an absorber
ghostBall - a boolean that specifies whether the ball is a ghost ball
Method Detail

getShape

public Circle09 getShape()
returns the shape of the ball. this method overrides the method of Gizmo.

Overrides:
getShape in class Gizmo
Returns:
the shape of the ball

getMass

public double getMass()
returns the mass of the ball.

Returns:
the mass of the ball

setVelocity

public void setVelocity(Vect v)
sets the velocity of the ball. If the ball is in an absorber the velocity cannot be changed.

Parameters:
v - the new velocity of the ball

isGhostBall

public boolean isGhostBall()
checks if the ball is a ghost ball.

Returns:
true if the ball is a ghost ball

getVelocity

public Vect getVelocity()
returns the velocity of the ball.

Returns:
the velocity of the ball

isInAbsorber

public boolean isInAbsorber()
returns if the ball is in an absorber or not.

Returns:
true if the ball is in an absorber

setInAbsorber

public void setInAbsorber(boolean bool)
sets the state of whether the ball is in an absorber.

Parameters:
bool - a boolean that states if the ball is in an absorber

changeCenter

public void changeCenter(Vect loc)
moves the center of the ball to a new location.

Parameters:
loc - the new location of the center of the ball

action

public void action()
a ball does not have an action.

Overrides:
action in class Gizmo