public class Pellets
extends java.lang.Object
SnakesGame
Constructor and Description |
---|
Pellets(java.awt.Color c,
int num)
Create the new pellets, with the given color at randomly chosen positions.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public Pellets(java.awt.Color c, int num)
c
- the pellet colornum
- the number of pelletspublic boolean onPosition(java.awt.Point p)
p
- the position to testtrue
if a pellet lies on p; false
otherwisepublic void remove(java.awt.Point p)
p
- the Point that has the pellet to removepublic boolean allGone()
true
if there are no more pellets; false
otherwisepublic void paint(java.awt.Graphics g)
g
- the Graphics pane on which to draw the pellet