import java.awt.Graphics; public class Square { private int x; private int y; private int speed; private int xMax; private int yMax; private int size; public Square(int xStart, int yStart, int width, int height) { x = xStart; y = yStart; xMax = width; yMax = height; speed = 5; size = 10; } public void move(double direction) { x += (int)(speed * Math.cos(direction)); y += (int)(speed * Math.sin(direction)); if (x < -size) {x = xMax;} if (x > xMax) {x = -size;} if (y < -size) {y = yMax;} if (y > yMax) {y = -size;} } public void setSpeed(int newSpeed) { speed = newSpeed; } public int getX() {return x;} public int getY() {return y;} public int getSpeed() {return speed;} public int getAreaWidth() {return xMax;} public int getAreaHeight() {return yMax;} public void draw(Graphics g) { g.setColor(new Color(255, 0, 0)); g.fillRect(x, y, size, size); } }