Skip to content

Commit

Permalink
#6 브릿지 패턴 예제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
soyeon207 committed Jun 8, 2021
1 parent 73ad573 commit 9847fd2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions _posts/2021-04-24-bridge-pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ tags: [디자인패턴, 브리지패턴, 구조패턴]

**Implementor : 기능 구현을 위한 인터페이스**
```Java
public interface MakeHandler() {
public interface MakeHandler {
public void prepareIngredient();
public void stuffingIngredient();
}
```

**ConcreteImplementor : 실제 기능 구현**
```Java
public class PotatoHotdogMethod() implements MakeHandler {
public class PotatoHotdogMethod implements MakeHandler {
public void prepareIngredient() {
System.out.println("감자 준비");
}
Expand All @@ -39,7 +39,7 @@ public class PotatoHotdogMethod() implements MakeHandler {
}
}

public class CheeseHotdogMethod() implements MakeHandler {
public class CheeseHotdogMethod implements MakeHandler {
public void prepareIngredient() {
System.out.println("치즈 준비");
}
Expand All @@ -52,19 +52,19 @@ public class CheeseHotdogMethod() implements MakeHandler {

**Abstraction : 기능 계층의 최상위 클래스**
```Java
public abstract class HotDog() {
public abstract class HotDog {
private MakeHandler makeHandler;

public HotDog(MakeHandler makeHandler) {
this.makeHandler = makeHandler;
}

public void prepareIngredient() {
makeHandler.prepareIngredient;
makeHandler.prepareIngredient();
}

public void stuffingIngredient() {
makeHandler.stuffingIngredient;
makeHandler.stuffingIngredient();
}

public abstract void fry();
Expand Down Expand Up @@ -99,9 +99,9 @@ public class CheeseHotDog extends HotDog {

```Java
public class Main {
public static void Main(String args[]) {
public static void main(String args[]) {
HotDog cheeseHotDog = new CheeseHotDog(new CheeseHotdogMethod());
HotDog potatoHotDog = new PotatoHotDog(new PotatoHotDogMethod());
HotDog potatoHotDog = new PotatoHotDog(new PotatoHotdogMethod());
cheeseHotDog.fry();
cheeseHotDog.prepareIngredient();
cheeseHotDog.stuffingIngredient();
Expand Down

0 comments on commit 9847fd2

Please sign in to comment.