-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHistoryCommand.java
More file actions
36 lines (29 loc) · 809 Bytes
/
HistoryCommand.java
File metadata and controls
36 lines (29 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.io.File;
import java.util.LinkedList;
public class HistoryCommand implements Command {
private File curDirectory;
private LinkedList<? extends Command> history;
HistoryCommand(File curDirectory, LinkedList<? extends Command> history) {
this.curDirectory = curDirectory;
this.history = history;
}
@Override
public File execute() {
System.out.println("HISTORY OF COMMANDS:");
int counter = 0;
for (Command command : history) {
++counter;
System.out.println(counter + " " + command.name());
}
return curDirectory;
}
@Override
public File cancel() {
return curDirectory;
//do nothing
}
@Override
public String name() {
return "undo";
}
}