Class Banana

java.lang.Object
  extended by Banana

public class Banana
extends java.lang.Object

This class represents a banana. It keeps track of the position of the banana, its radius, its direction and its velocity. The banana produces a shock wave when it splats after hitting a gorilla or a building. The class keeps track of the range in which a banana's shock wave hurts gorillas as well as the progress of the shock wave.

Field Summary
static int MAX_SHOCK_WAVE_RADIUS
          The reach of the bananas' explosion shock waves
static double RADIUS
          The radius of all bananas
 
Constructor Summary
Banana(double x, double y, double xVel, double yVel)
          Makes a new banana with the specified position.
 
Method Summary
 int getCurrentShockWaveRadius()
          Returns the current radius of the banana's shock wave
 double getX()
          Returns the x coordinate of the center of the banana
 double getY()
          Returns the y coordinate of the center of the banana
 boolean isSplatting()
          Indicates whether the banana splatted already.
 void splat()
          Sets the banana to the splatting state.
 void tick(double time, double gravity)
          Simulates the behavior of the banana for one tick.
 java.lang.String toString()
          Returns information about the banana as a string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RADIUS

public static final double RADIUS
The radius of all bananas


MAX_SHOCK_WAVE_RADIUS

public static final int MAX_SHOCK_WAVE_RADIUS
The reach of the bananas' explosion shock waves

Constructor Detail

Banana

public Banana(double x,
              double y,
              double xVel,
              double yVel)
Makes a new banana with the specified position. The banana moves along the two coordinate axes at the specified velocities.

Parameters:
x - The x coordinate of the center of the banana.
y - The y coordinate of the center of the banana.
xVel - The velocity of the banana in the direction of the x axis.
yVel - The velocity of the banana in the direction of the y axis.
Method Detail

splat

public void splat()
Sets the banana to the splatting state. The banana should not move anymore


getX

public double getX()
Returns the x coordinate of the center of the banana

Returns:
the x coordinate of the center of the banana

getY

public double getY()
Returns the y coordinate of the center of the banana

Returns:
the y coordinate of the center of the banana

isSplatting

public boolean isSplatting()
Indicates whether the banana splatted already.

Returns:
true if the banana is splatting, false otherwise

getCurrentShockWaveRadius

public int getCurrentShockWaveRadius()
Returns the current radius of the banana's shock wave

Returns:
the current radius of the banana's shock wave

tick

public void tick(double time,
                 double gravity)
Simulates the behavior of the banana for one tick.

Parameters:
time - The length of a tick
gravity - Gravitational constant

toString

public java.lang.String toString()
Returns information about the banana as a string. This will help you with debugging.

Overrides:
toString in class java.lang.Object