-
Notifications
You must be signed in to change notification settings - Fork 0
/
CmdListEquipmentStatus.java
34 lines (33 loc) · 1.8 KB
/
CmdListEquipmentStatus.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
32
33
34
import java.util.ArrayList;
import java.util.List;
public class CmdListEquipmentStatus implements Command{
@Override
public void execute(String[] cmdParts) throws ExInsufficientCmdArgs, ExEquipmentCodeInUse, ExEquipmentCodeNotFound, ExMemberIdInUse, ExInvalidNewDay, ExInvalidDayFormat, ExMemberNotFound, ExNoAvailableBorrow, ExExistBorrowMember {
Club c = Club.getInstance();
for(Equipment equipment:c.getAllEquipments()){
System.out.printf("[%s %s]\n",equipment.getEqCode(),equipment.getName());
int count=0;
for(EquipmentSet equipmentSet: equipment.getAllEquipmentSets()){
if(!equipmentSet.isUndo()){
System.out.printf(" %s\n",equipmentSet.getEqSetCode());
System.out.printf(" Current status: %s\n",equipmentSet.getBorrowMember()==null?
"Available":String.format("%s %s borrows for %s to %s",equipmentSet.getBorrowMember().getId(),
equipmentSet.getBorrowMember().getName(),equipmentSet.getBorrowItems().getStartDay(),
equipmentSet.getBorrowItems().getEndDay()));
List<String> dayList=new ArrayList<>();
for(RequestItem requestItem: equipmentSet.getRequestItemArrayList()){
dayList.add(requestItem.getStartDay()+" to "+requestItem.getEndDay());
}
if(dayList.size()>0){
System.out.printf(" Requested period(s): %s\n",String.join(", ",dayList));
}
count++;
}
}
if(count==0){
System.out.println("We do not have any sets for this equipment.");
}
System.out.println();
}
}
}