class Ball {
private int x;
private int y;
private int vx;
private int vy;
private int left;
private int right;
private int top;
private int bottom;
public Ball(int x, int y, int vx, int vy, int l, int t, int r, int b) {
this.x = x;
this.y = y;
this.vx = vx;
this.vy = vy;
right = r;
left = l;
top = t;
bottom = b;
}
public void forward() {
x = x + vx;
y = y + vy;
if (x < left || x > right) {
vx = -vx;
}
if (y < top || y > bottom) {
vy = -vy;
}
}