0

okay i've been using bluej for learning purposes but i kind of hit a snag would it be possible for someone to code me a main method so that it works as stand alone program please

public class Circle
{
    private int diameter;
    private int xPosition;
    private int yPosition;
    private String color;
    private boolean isVisible;
    public Circle()
    {
        diameter = 30;
        xPosition = 20;
        yPosition = 60;
        color = "blue";
        isVisible = false;
    }
/Make visible
/
    public void makeVisible()
    {
        isVisible = true;
        draw();
    }
    /Make invisible
        /
    public void makeInvisible()
    {
        erase();
        isVisible = false;
    }
/Move circle up.
/
    public void moveUp()
    {
        moveVertical(-20);
    }
    /Move circle down.
    /
    public void moveDown()
    {
        moveVertical(20);
    }
    public void moveRight()
    {
        moveHorizontal(20);
    }
/Move circle left.
/
    public void moveLeft()
    {
        moveHorizontal(-20);
    }
/Move circle horizontally 
/
    public void moveHorizontal(int distance)
    {
        erase();
        xPosition += distance;
        draw();
    }
/Move vertically
/
    public void moveVertical(int distance)
    {
        erase();
        yPosition += distance;
        draw();
    }
/move horizontally slow
/
    public void slowMoveHorizontal(int distance)
    {
        int delta;

        if(distance < 0) 
        {
            delta = -1;
            distance = -distance;
        }
        else 
        {
            delta = 1;
        }

        for(int i = 0; i < distance; i++)
        {
            xPosition += delta;
            draw();
        }
    }
/move vertically slow
/
    public void slowMoveVertical(int distance)
    {
        int delta;

        if(distance < 0) 
        {
            delta = -1;
            distance = -distance;
        }
        else 
        {
            delta = 1;
        }

        for(int i = 0; i < distance; i++)
        {
            yPosition += delta;
            draw();
        }
    }
/Change size 
/
    public void changeSize(int newDiameter)
    {
        erase();
        diameter = newDiameter;
        draw();
    }
/Change color
/
    public void changeColor(String newColor)
    {
        color = newColor;
        draw();
    }
    private void draw()
    {
        if(isVisible) {
            Canvas canvas = Canvas.getCanvas();
            canvas.draw(this, color, new Ellipse2D.Double(xPosition, yPosition, 
                                                          diameter, diameter));
            canvas.wait(10);
        }
    }

/deletes circle
/
    private void erase()
    {
        if(isVisible) {
            Canvas canvas = Canvas.getCanvas();
            canvas.erase(this);
        }
    }
}

Edited by masijade: n/a

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by masijade
0

We are not a (home)work service. Try it yourself, and post your attempt along with detailed information if it "doesn't work".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.