

void start();
void shutdown();
}
public class Laptop implements Computer {
public void start() {
System.out.print("Laptop is started");
}
public void shutdown() {
System.out.print("Laptop is shutdown");
}
}
public interface Command {
void execute();
void undo();
}
public class StartLaptop implements Command {
Computer theComputer;
public StartLaptop (Computer newComputer ) {
theComputer = newComputer;
}
public void execute() {
theComputer.start();
}
public void undo() {
theComputer.shutdown();
}
}
Below is the video tutorial about the Command pattern.

No comments:
Post a Comment