import java.awt.*; abstract class Shape { int curX = 5, curY = 10; Color color; World world; int coords[][]; Shape(World world) { this.world = world; } void drawSquare(Graphics g, int x, int y) { g.setColor(color); g.fillRect(x + 1, y + 1, world.squareWidth() - 2, world.squareHeight() - 2); g.setColor(color.brighter()); g.drawLine(x, y + world.squareHeight() - 1, x, y); g.drawLine(x, y, x + world.squareWidth() - 1, y); g.setColor(color.darker()); g.drawLine(x + 1, y + world.squareHeight() - 1, x + world.squareWidth() - 1, y + world.squareHeight() - 1); g.drawLine(x + world.squareWidth() - 1, y + world.squareHeight() - 1, x + world.squareWidth() - 1, y + 1); } void draw(Graphics g) { Dimension size = world.getSize(); int boardTop = (int) size.getHeight() - world.BoardHeight * world.squareHeight(); for (int i = 0; i < 4; ++i) { int x = curX + this.x(i); int y = curY - this.y(i); drawSquare(g, 0 + x * world.squareWidth(), boardTop + (world.BoardHeight - y - 1) * world.squareHeight()); } } private void setX(int index, int x) { coords[index][0] = x; } private void setY(int index, int y) { coords[index][1] = y; } public int x(int index) { return coords[index][0]; } public int y(int index) { return coords[index][1]; } }