import java.awt.*; class Block { final static int SIZE = 20; // pixels int x, y; Color color; Block(int x, int y, Color c) { this.x = x; this.y = y; this.color = c; } void draw(Graphics g) { int xp = this.x * SIZE + SIZE/2, yp = this.y * SIZE + SIZE / 2; g.setColor(this.color); g.fillRect(xp, yp, SIZE, SIZE); g.setColor(Color.BLACK); g.drawRect(xp, yp, SIZE, SIZE); } void move(int dx, int dy) { this.x += dx; this.y += dy; } }