Typically command pattern is implemented using
interfaces and concrete classes. Refactor the code to use the same
This commit is contained in:
parent
9ff5b9e7c0
commit
3ae7466647
@ -26,15 +26,14 @@ package com.iluwatar.command;
|
||||
/**
|
||||
* Interface for Commands.
|
||||
*/
|
||||
public abstract class Command {
|
||||
public interface Command {
|
||||
|
||||
public abstract void execute(Target target);
|
||||
public void execute(Target target);
|
||||
|
||||
public abstract void undo();
|
||||
public void undo();
|
||||
|
||||
public abstract void redo();
|
||||
public void redo();
|
||||
|
||||
@Override
|
||||
public abstract String toString();
|
||||
public String toString();
|
||||
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ package com.iluwatar.command;
|
||||
/**
|
||||
* InvisibilitySpell is a concrete command.
|
||||
*/
|
||||
public class InvisibilitySpell extends Command {
|
||||
public class InvisibilitySpell implements Command {
|
||||
|
||||
private Target target;
|
||||
|
||||
|
@ -26,7 +26,7 @@ package com.iluwatar.command;
|
||||
/**
|
||||
* ShrinkSpell is a concrete command.
|
||||
*/
|
||||
public class ShrinkSpell extends Command {
|
||||
public class ShrinkSpell implements Command {
|
||||
|
||||
private Size oldSize;
|
||||
private Target target;
|
||||
|
Loading…
x
Reference in New Issue
Block a user