Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Ball extends Block{
- private int xSpeed;
- private int ySpeed;
- public Ball() {
- super(200, 200,10,10);
- xSpeed = 3;
- ySpeed = 1;
- }
- //add other Ball constructors
- //mutator methods for x and y speed
- public void moveAndDisplay(){
- //draw a white ball at old ball location using inherited display(color col) method
- setX(getX()+xSpeed);
- //setY too
- //draw ball at new location
- //using inherited display() method
- }
- //equals method
- //should call Block’s equals method
- //and also check x and y speed
- //accessor methods for speed
- public String toString() {
- //should call Block’s toString
- //and also add x and y speed
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment