Wednesday, February 4, 2015

[ADF1] - Day 1: Draw picture using BlueJ's example



Add code draw RECTANGLE:

public class Rectange
{
    private int xSize;
    private int ySize;
    private int xPosition;
    private int yPosition;
    private String color;
    private boolean isVisible;

public Rectange()
    {
        xSize = 100;
        ySize = 5;
        xPosition = 60;
        yPosition = 50;
        color = "magenta";
        isVisible = false;
    }

public void changeSize(int new_xSize, int new_ySize)
    {
        erase();
        xSize = new_xSize;
        ySize = new_ySize;
        draw();
    }

private void draw()
    {
        if(isVisible) {
            Canvas canvas = Canvas.getCanvas();
            canvas.draw(this, color,
                    new Rectangle(xPosition, yPosition, xSize, ySize));
            canvas.wait(10);
        }
    }
}

Add code to draw SunRiseUp: with loop pass by user


Draw house with Sun auto Rise and Up:


No comments:

Post a Comment