Command pattern

This commit is contained in:
kim
2021-01-20 23:30:00 +09:00
parent 77b361ba96
commit aa29dc4df1
4 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
package Command;
public class StringPrintCommand implements Command{
private final String string;
public StringPrintCommand(String string) {
this.string = string;
}
@Override
public void execute() {
System.out.println(this.string);
}
@Override
public int compareTo(Command o) {
return this.string.length() - ((StringPrintCommand) o).string.length();
}
}