class Girl
{
public void showAppearance()
{
System.out.println("the girl: face without make up");
}
}
class TakeFlower extends Girl
{
Girl girl=null;
public TakeFlower(Girl girl)
{
this.girl=girl;
}
public void showAppearance()
{
girl.showAppearance();
takeFlower();
}
public void takeFlower()
{
System.out.println(" take flower");
}
}
class TakeNecklace extends Girl
{
Girl girl=null;
public TakeNecklace(Girl girl)
{
this.girl=girl;
}
public void showAppearance()
{
girl.showAppearance();
takeNecklace();
}
public void takeNecklace()
{
System.out.println(" take necklace");
}
}
class TakeEarrings extends Girl
{
Girl girl=null;
public TakeEarrings(Girl girl)
{
this.girl=girl;
}
public void showAppearance()
{
girl.showAppearance();
takeEarrings();
}
public void takeEarrings()
{
System.out.println(" take earrings");
}
}
public class DecoratorPatternTest
{
public static void main(String[] args)
{
Girl aGirl=new TakeNecklace(new TakeFlower(new Girl()));
aGirl.showAppearance();
aGirl=new TakeFlower(new TakeEarrings(new Girl()));
aGirl.showAppearance();
}
}