Thursday, March 5, 2015

ADF1 - Day 2.2 - Animation of picture

CLASS HOUSE:

public class House
{
    private Square wall;
    private Square window;
    private Triangle roof;

    public House()
    {
        wall = new Square();
        wall.moveVertical(80);
        wall.changeSize(100);
        wall.makeVisible();

        window = new Square();
        window.changeColor("black");
        window.moveHorizontal(20);
        window.moveVertical(100);
        window.makeVisible();

        roof = new Triangle();
        roof.changeSize(50, 140);
        roof.moveHorizontal(60);
        roof.moveVertical(70);
        roof.makeVisible();
    }

    public void setBlackAndWhite()
    {
        wall.changeColor("black");
        window.changeColor("white");
        roof.changeColor("black");          
    }

    public void setColor()
    {
        wall.changeColor("red");
        window.changeColor("black");
        roof.changeColor("green");          
    }


}

CLASS SUN:

public class Sun
{  
    private Circle image;
    public Sun(){
        image = new Circle();
        image.changeColor("yellow");
        image.changeSize(60);
        image.makeVisible();
    }

    public void set(){
        image.slowMoveVertical(300);
    }
 
    public void rise(){
        image.slowMoveVertical(-300);
    }

}

STRUCTURE OF A METHOD:

returnType functionName(parameterList)
{
       body of method
}