Class Ball

java.lang.Object
  |
  +--Ball
All Implemented Interfaces:
SimThing

public class Ball
extends java.lang.Object
implements SimThing

A small ball object that wanders randomly around a bounded area. CSE143 lecture demo Au01, Sp03

Version:
10/18/01, 4/16/03
Author:
Hal Perkins

Constructor Summary
Ball(int x, int y, int dx, int dy, java.awt.Color c, int diameter, int maxx, int maxy)
          Construct a new Ball
 
Method Summary
 void action()
          Perform an appropriate action on each cycle of the simulation
 void paintComponent(java.awt.Graphics g)
          Display this ball on the given graphics context
 java.lang.String toString()
          Return a String representation of this Ball
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ball

public Ball(int x,
            int y,
            int dx,
            int dy,
            java.awt.Color c,
            int diameter,
            int maxx,
            int maxy)
Construct a new Ball

Parameters:
x - initial x pixel coordinate of center of the ball
y - initial y pixel coordinate of center of the ball
dx - initial velocity in x direction in pixels per cycle
dy - initial velocity in y direction in pixels per cycle
c - color of the ball
diameter - diameter of the ball in pixels
maxx - largest possible x coordinate
maxy - largest possible y coordinate
Method Detail

action

public void action()
Perform an appropriate action on each cycle of the simulation

Specified by:
action in interface SimThing

paintComponent

public void paintComponent(java.awt.Graphics g)
Display this ball on the given graphics context

Specified by:
paintComponent in interface SimThing
Parameters:
g - the graphics context where this ball should be drawn

toString

public java.lang.String toString()
Return a String representation of this Ball

Overrides:
toString in class java.lang.Object


Generated by BlueJ