42 lines
644 B
Java
42 lines
644 B
Java
import java.awt.Color;
|
|
import java.awt.Graphics;
|
|
|
|
public abstract class Shape {
|
|
private int x;
|
|
private int y;
|
|
private Color color;
|
|
|
|
public Shape(int x, int y) {
|
|
this.x = x;
|
|
this.y = y;
|
|
color = new Color((float) Math.random(), (float) Math.random(), (float) Math.random());
|
|
}
|
|
|
|
public int getX() {
|
|
return x;
|
|
}
|
|
|
|
public void setX(int x) {
|
|
this.x = x;
|
|
}
|
|
|
|
public int getY() {
|
|
return y;
|
|
}
|
|
|
|
public void setY(int y) {
|
|
this.y = y;
|
|
}
|
|
|
|
public abstract boolean isVisible(int w, int h);
|
|
|
|
public abstract boolean isIn(int x, int y);
|
|
|
|
public void draw(Graphics g) {
|
|
g.setColor(color);
|
|
}
|
|
|
|
public static void testShape() {
|
|
}
|
|
}
|