Objektorientierte Programmierung WS 2013/2014 - Datei BoundedBall.java
import java.awt.*;
// BoundedBall is a subclass of MovableBall
public class BoundedBall extends MovableBall {
private int leftx;
private int rightx;
private int lowy;
private int highy;
// constructor
public BoundedBall(int x, int y, int r, int lx, int rx, int ly, int hy) {
super(x, y, r);
leftx = lx;
rightx = rx;
lowy = ly;
highy = hy;
}
public void move() {
super.move();
if (x() < leftx || x() > rightx) {
setMotion(-xMotion(), yMotion());
}
if (y() < lowy || y() > highy) {
setMotion(xMotion(), -yMotion());
}
}
}
Generiert mit Camelot | Probleme mit Camelot? | Geändert am: 05.11.2013


