坦克大战(一期)-设计模式-templateMethod

DesignPatterns
bingor 2 years ago
parent e084821a98
commit df100d6237

@ -0,0 +1,43 @@
package com.msb.templateMethod;/**
* @Author bingor
* @Date 2022/10/19 9:47
* @Description: com.msb.templateMethod
* @Version: 1.0
*/
/**
*@ClassName Main
*@Description TODO
*@Author bingor
*@Date 2022/10/19 9:47
*@Version 3.0
*/
public class Main {
public static void main(String[] args) {
Father father = new Child();
father.exe();
}
}
abstract class Father {
public void exe() {
opt1();
opt2();
}
public abstract void opt1();
public abstract void opt2();
}
class Child extends Father {
@Override
public void opt1() {
System.out.println("child:opt1");
}
@Override
public void opt2() {
System.out.println("child:opt2");
}
}
Loading…
Cancel
Save