-
Notifications
You must be signed in to change notification settings - Fork 0
/
CmdChangeTeam.java
31 lines (24 loc) · 1.01 KB
/
CmdChangeTeam.java
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
public class CmdChangeTeam extends RecordedCommand{
private Company company;
private JoinReference newJoinReference;
private JoinReference preJoinReference;
public void execute(String[] cmdParts) throws ExInsufficientArguments, ExEmployeeNotFound, ExEmployeeJoinedTeam, ExTeamNotExist, ExTeamSame{
if(cmdParts.length != 3)
throw new ExInsufficientArguments();
company = Company.getInstance();
company.searchEmployee(cmdParts[1]);
company.searcTeam(cmdParts[2]);
preJoinReference = company.searchJoinReference(cmdParts[1]);
newJoinReference = company.changeTeam(cmdParts[1], cmdParts[2]);
pushUndo(this);
System.out.println("Done.");
}
public void undo(){
company.removeJoinReference(newJoinReference);
company.addJoinReference(preJoinReference);
}
public void redo(){
company.removeJoinReference(preJoinReference);
company.addJoinReference(newJoinReference);
}
}