2015-08-21 23:19:55 +03:00
|
|
|
package com.iluwatar.templatemethod;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Halfling thief uses {@link StealingMethod} to steal.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class HalflingThief {
|
|
|
|
|
2015-11-01 21:29:13 -05:00
|
|
|
private StealingMethod method;
|
2015-08-21 23:19:55 +03:00
|
|
|
|
2015-11-01 21:29:13 -05:00
|
|
|
public HalflingThief(StealingMethod method) {
|
|
|
|
this.method = method;
|
|
|
|
}
|
2015-08-21 23:19:55 +03:00
|
|
|
|
2015-11-01 21:29:13 -05:00
|
|
|
public void steal() {
|
|
|
|
method.steal();
|
|
|
|
}
|
2015-08-21 23:19:55 +03:00
|
|
|
|
2015-11-01 21:29:13 -05:00
|
|
|
public void changeMethod(StealingMethod method) {
|
|
|
|
this.method = method;
|
|
|
|
}
|
2015-08-21 23:19:55 +03:00
|
|
|
}
|