Thứ Năm, 26 tháng 2, 2015

BuildClass-EP2


  • Create class of following images:


Code:

Class House:

/**
 * House
 *
 * @author (MZ)
 * @version (1.0)
 */
public class House
{
    private Triangle roof;
    private Square wall;
    private Square window;
    private Circle hill;

    /**
     * Constructor for objects of class House
     */
    public House()
    {
        roof = new Triangle();
        roof.makeVisible();
        roof.changeColor("green");
        roof.changeSize(50,120);
        roof.moveRight();
        roof.moveDown();
        roof.moveDown();
        roof.moveDown();
        roof.moveRight();
        roof.moveRight();
       
        wall = new Square();
        wall.makeVisible();
        wall.changeSize(100);
        wall.moveDown();
        wall.moveDown();
        wall.moveDown();
        wall.moveDown();
        wall.moveVertical(-5);
       
        window = new Square();
        window.makeVisible();
        window.moveDown();
        window.moveDown();
        window.moveDown();
        window.moveDown();
        window.changeColor("black");
        window.moveDown();
        window.moveRight();
       
        hill = new Circle();
        hill.makeVisible();
        hill.changeColor("green");
        hill.changeSize(440);
        hill.moveVertical(150);
        hill.moveLeft();
        hill.moveLeft();
        hill.moveLeft();
        hill.moveLeft();
        hill.moveLeft();
        hill.moveLeft();
    }
}

Class Sun:

/**
 * Sun
 *
 * @author (MZ)
 * @version (1.0)
 */
public class Sun
{
    private Circle sun;
    /**
     * Constructor for objects of class Sun
     */
    public Sun()
    {
       sun = new Circle();
       sun.makeVisible();
       sun.changeColor("yellow");
       sun.changeSize(50);
       sun.moveHorizontal(220);
    }

}
   


CreateObject-DrawPicture


Draw the images using tool: