Template Method
μμ μΆμ ν΄λμ€κ° λλ΅μ μΈ λ‘μ§μ μ‘μλκ³ μ€μ λ‘ μμΈν ꡬνμ μμμ λ°μ ꡬνμ κ°μ νλλ‘ νλκ²
public abstract class Car {
public void playWithOwner() {
System.out.println("Start");
play();
runSomeThing();
}
abstract void play();
void runSomething() {
System.out.println("Something");
}
}
public class Auto extends Car {
@Override
void play() {
System.out.println("move Car");
}
void runSomething() {
System.out.println("Something others");
}
}
public class Main {
public static void main(String[] args) {
Car auto = new Auto();
auto.playWithOwner();
}
}
Start
move Car
Something others
μ°Έκ³ μλ£
β Factory Method Decorator Pattern β