package Houses;
import java.util.*;
public class House
{
protected int area;
protected Door door;
public House(int area)
{
this.area = area;
door = new Door();
}
public final int getArea()
{
return area;
}
public final void setArea(int value)
{
area = value;
}
public final Door getDoor()
{
return door;
}
public final void setDoor(Door value)
{
door = value;
}
public void ShowData()
{
System.out.printf("I am a house, my area is %1$s m2." + "\r\n", area);
}
}
public class Door
{
protected String color;
public Door()
{
color = "Brown";
}
public Door(String color)
{
this.color = color;
}
public final String getColor()
{
return color;
}
public final void setColor(String value)
{
color = value;
}
public final void ShowData()
{
System.out.printf("I am a door, my color is %1$s." + "\r\n", color);
}
}
public class SmallApartment extends House
{
public SmallApartment()
{
super(50);
}
@Override
public void ShowData()
{
System.out.println("I am an apartment, my area is " + area + " m2");
}
}
public class Person
{
protected String name;
protected House house;
public Person()
{
name = "Juan";
house = new House(150);
}
public Person(String name, House house)
{
this.name = name;
this.house = house;
}
public final String getName()
{
return name;
}
public final void setName(String value)
{
name = value;
}
public final House getHouse()
{
return house;
}
public final void setHouse(House value)
{
house = value;
}
public final void ShowData()
{
System.out.printf("My name is %1$s." + "\r\n", name);
house.ShowData();
house.getDoor().ShowData();
}
}
public class Main
{
public static void main(String[] args)
{
boolean debug = true;
SmallApartment mySmallApartament = new SmallApartment();
Person myPerson = new Person();
myPerson.setName("Juan");
myPerson.setHouse(mySmallApartament);
myPerson.ShowData();
if (debug)
{
new Scanner(System.in).nextLine();
}
}
}