added template method sample
This commit is contained in:
@ -0,0 +1,17 @@
|
||||
package com.iluwatar;
|
||||
|
||||
public abstract class StealingMethod {
|
||||
|
||||
protected abstract String pickTarget();
|
||||
|
||||
protected abstract void confuseTarget(String target);
|
||||
|
||||
protected abstract void stealTheItem(String target);
|
||||
|
||||
public void steal() {
|
||||
String target = pickTarget();
|
||||
System.out.println("The target has been chosen as " + target + ".");
|
||||
confuseTarget(target);
|
||||
stealTheItem(target);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user