示例#1
0
  public Operation ScanIn(Integer cardId, Date date, Time time) {
    Operation operation = new Operation(cardId, time, TypeOfOperation.IN);

    if (turniketDB.getOperations().containsKey(cardId)) {

      Map<Date, List<Operation>> dateListMap = turniketDB.getOperations().get(cardId);

      if (dateListMap.containsKey(date)) {
        dateListMap.get(date).add(operation);
      } else {
        List<Operation> operations = new ArrayList<>();
        operations.add(operation);
        dateListMap.put(date, operations);
      }

    } else {
      List<Operation> operations = new ArrayList<>();
      operations.add(operation);
      Map<Date, List<Operation>> map = new HashMap<>();
      map.put(date, operations);
      turniketDB.getOperations().put(cardId, map);
    }

    return operation;
  }
示例#2
0
 @Override
 public boolean deleteCard(Integer cardId) {
   if (turniketDB.getCards().containsKey(cardId)) {
     turniketDB.getCards().remove(cardId);
     turniketDB.getOperations().remove(cardId);
     return true;
   } else {
     return false;
   }
 }
示例#3
0
 public Operation ScanOut(Integer cardId, Date date, Time time) {
   Operation operation = new Operation(cardId, time, TypeOfOperation.OUT);
   turniketDB.getOperations().get(cardId).get(date).add(operation);
   return operation;
 }