import java.awt.*;

public class Racket {
    public int x, y;                    // upper left corner
    private int vY;                     // speed
    public int width, height;
    private final Color color;

    public Racket(int x, int y, int vY, int width, int height, Color color)
    {
        this.x = x;
        this.y = y;
        this.vY = vY;
        this.width = width;
        this.height = height;
        this.color = color;
    }

    public void speedUp()
    {
        this.vY += 5;
    }

    public void move(int y, int maxY)
    {
        if (y - height / 2 >= 0 && y + height / 2 <= maxY) {
            this.y = y - height / 2;
        }
    }

    public void moveUp()
    {
        if (y - vY >= 0) {
            y -= vY;
        }
    }

    public void moveDown(int maxY)
    {
        if (y + height + vY <= maxY) {
            y += vY;
        }
    }

    public void draw(Graphics2D g2)
    {
        g2.setColor(color);
        g2.fillRect(x, y, width, height);
    }
}
