Typically command pattern is implemented using

interfaces and concrete classes. Refactor the
code to use the same
This commit is contained in:
Rakesh Venkatesh 2020-08-03 16:51:30 +02:00
parent 9ff5b9e7c0
commit 3ae7466647
3 changed files with 7 additions and 8 deletions

View File

@ -26,15 +26,14 @@ package com.iluwatar.command;
/** /**
* Interface for Commands. * 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 String toString();
public abstract String toString();
} }

View File

@ -26,7 +26,7 @@ package com.iluwatar.command;
/** /**
* InvisibilitySpell is a concrete command. * InvisibilitySpell is a concrete command.
*/ */
public class InvisibilitySpell extends Command { public class InvisibilitySpell implements Command {
private Target target; private Target target;

View File

@ -26,7 +26,7 @@ package com.iluwatar.command;
/** /**
* ShrinkSpell is a concrete command. * ShrinkSpell is a concrete command.
*/ */
public class ShrinkSpell extends Command { public class ShrinkSpell implements Command {
private Size oldSize; private Size oldSize;
private Target target; private Target target;