package com.racoon.util.Design;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class FacadeSample extends Activity {
/* 퍼사드 -여러개의 클래스의 기능들을 종합하여 특정 기능을 실행할때
* 그것들을 묶어서 한번에 처리하도록한다
* */
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Man man = new Man();
man.Eating();
}
interface IHuman{
void Eat() ;
void Digest();
void Excretion();
}
abstract class Human implements IHuman{
Mouse mouse;
Body body;
Ass ass;
public Human(){
mouse = new Mouse();
body = new Body();
ass = new Ass();
}
public void Eating(){
mouse.Eat();
body.Digest();
ass.Excretion();
}
}
class Man extends Human{
public Man(){
super();
}
@Override
public void Eat() {
// TODO Auto-generated method stub
mouse.Eat();
}
@Override
public void Digest() {
// TODO Auto-generated method stub
body.Digest();
}
@Override
public void Excretion() {
// TODO Auto-generated method stub
ass.Excretion();
}
}
class Ass{
public void Excretion(){
Log.d("Design", "배설하다");
}
}
class Body{
public void Digest(){
Log.d("Design", "소화시키다");
}
}
class Mouse{
public void Eat() {
Log.d("Design", "먹다");
}
}
}
'Program > 디자인패턴' 카테고리의 다른 글
observer 패턴 (0) | 2012.10.05 |
---|---|
FlyweightSample (0) | 2012.09.05 |
ProxySample (0) | 2012.09.05 |
디자인패턴 스터디 1주차 - 추상팩토리,빌더,팩토리메소드 (0) | 2012.08.22 |