Formatted all files to the same standard
This commit is contained in:
@ -1,17 +1,17 @@
|
||||
package com.iluwatar;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Template Method (StealingMethod) defines skeleton for the algorithm and
|
||||
* subclasses (HitAndRunMethod, SubtleMethod) fill in the blanks.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
|
||||
public static void main(String[] args) {
|
||||
HalflingThief thief = new HalflingThief(new HitAndRunMethod());
|
||||
thief.steal();
|
||||
thief.changeMethod(new SubtleMethod());
|
||||
thief.steal();
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
HalflingThief thief = new HalflingThief(new HitAndRunMethod());
|
||||
thief.steal();
|
||||
thief.changeMethod(new SubtleMethod());
|
||||
thief.steal();
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.iluwatar;
|
||||
/**
|
||||
*
|
||||
* Halfling thief uses StealingMethod to steal.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class HalflingThief {
|
||||
|
||||
@ -12,11 +12,11 @@ public class HalflingThief {
|
||||
public HalflingThief(StealingMethod method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
|
||||
public void steal() {
|
||||
method.steal();
|
||||
}
|
||||
|
||||
|
||||
public void changeMethod(StealingMethod method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
@ -3,14 +3,14 @@ package com.iluwatar;
|
||||
/**
|
||||
*
|
||||
* Template Method base class.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class StealingMethod {
|
||||
|
||||
protected abstract String pickTarget();
|
||||
|
||||
|
||||
protected abstract void confuseTarget(String target);
|
||||
|
||||
|
||||
protected abstract void stealTheItem(String target);
|
||||
|
||||
public void steal() {
|
||||
|
@ -9,12 +9,14 @@ public class SubtleMethod extends StealingMethod {
|
||||
|
||||
@Override
|
||||
protected void confuseTarget(String target) {
|
||||
System.out.println("Approach the " + target + " with tears running and hug him!");
|
||||
System.out.println("Approach the " + target
|
||||
+ " with tears running and hug him!");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stealTheItem(String target) {
|
||||
System.out.println("While in close contact grab the " + target + "'s wallet.");
|
||||
System.out.println("While in close contact grab the " + target
|
||||
+ "'s wallet.");
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user