Class Pellets

java.lang.Object
  extended by Pellets

public class Pellets
extends java.lang.Object

Pellets, to be eaten by Caterpillars in the Munch Game.

See Also:
MunchGame

Constructor Summary
Pellets(java.awt.Color c, int num)
          Create the new pellets, with the given color at randomly chosen positions.
 
Method Summary
 boolean allGone()
          Determine whether all of the pellets have been consumed.
 boolean onPosition(java.awt.Point p)
          Determine whether a pellet lies on the given position.
 void paint(java.awt.Graphics g)
          Draw the pellets on the given pane
 void remove(java.awt.Point p)
          Remove the pellet at Point p from the collection of pellets.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pellets

public Pellets(java.awt.Color c,
               int num)
Create the new pellets, with the given color at randomly chosen positions.

Parameters:
c - the pellet color
num - the number of pellets
Method Detail

onPosition

public boolean onPosition(java.awt.Point p)
Determine whether a pellet lies on the given position.

Parameters:
p - the position to test
Returns:
true if a pellet lies on p; false otherwise

remove

public void remove(java.awt.Point p)
Remove the pellet at Point p from the collection of pellets.

Parameters:
p - the Point that has the pellet to remove

allGone

public boolean allGone()
Determine whether all of the pellets have been consumed.

Returns:
true if there are no more pellets; false otherwise

paint

public void paint(java.awt.Graphics g)
Draw the pellets on the given pane

Parameters:
g - the Graphics pane on which to draw the pellet