示例#1
0
 // Create a new room location or add rooms to an existing location.
 // Note: if price <= 0 and the room location already exists, it maintains
 // its current price.
 @Override
 public boolean addRooms(int id, String location, int numRooms, int roomPrice) {
   Trace.info(
       "RM::addRooms(" + id + ", " + location + ", " + numRooms + ", $" + roomPrice + ") called.");
   Room curObj = (Room) readData(id, Room.getKey(location));
   synchronized (syncLock) {
     if (curObj == null) {
       // Doesn't exist; add it.
       Room newObj = new Room(location, numRooms, roomPrice);
       writeData(id, newObj.getKey(), newObj);
       Trace.info(
           "RM::addRooms(" + id + ", " + location + ", " + numRooms + ", $" + roomPrice + ") OK.");
     } else {
       // Add count to existing object and update price.
       curObj.setCount(curObj.getCount() + numRooms);
       if (roomPrice > 0) {
         curObj.setPrice(roomPrice);
       }
       writeData(id, curObj.getKey(), curObj);
       Trace.info(
           "RM::addRooms("
               + id
               + ", "
               + location
               + ", "
               + numRooms
               + ", $"
               + roomPrice
               + ") OK: "
               + "rooms = "
               + curObj.getCount()
               + ", price = $"
               + roomPrice);
     }
     return (true);
   }
 }
示例#2
0
 // Add room reservation to this customer.
 @Override
 public boolean cancelReserveRoom(int id, int customerId, String location) {
   return cancelReserveItem(id, customerId, Room.getKey(location), location);
 }
示例#3
0
 // Returns room price at this location.
 @Override
 public int queryRoomsPrice(int id, String location) {
   return queryPrice(id, Room.getKey(location));
 }
示例#4
0
 // Delete rooms from a location.
 @Override
 public boolean deleteRooms(int id, String location) {
   return deleteItem(id, Room.getKey(location));
 }