package resources.room; import java.util.Collection; import java.util.List; /** * A RoomDB is a representation of a collection of rooms. * * @author aakoeppe * */ public abstract class RoomDB { public Collection rooms; public RoomDB() { } /** * Adds a room the DB. * * @param r * the rooms to set */ /* pre: // // There is no Room in the input DB with the same building number and room number // as the Room to be added. // !exists (Room r_other; rooms.contains(r_other); r_other.building.buildingNumber == r.building.buildingNumber && r_other.roomNumber == r.roomNumber) && // The building of the given room is not empty and greater than 0 // // (r.building != null && r.building.buildingNumber > 0) && // // The room number is not empty and greater than 0 // (r.roomNumber != null) && (r.roomNumber > 0) && // // The room type is not null // (r.type != null); // // A room is in the output data if and only if it is the new // record to be added or it is in the input data. // post: forall (Room r_other; rooms'.contains(r_other) iff r_other.equals(r) || rooms.contains(r_other)); */ public abstract void addRoom(Room r); /** * Removes a room from the DB as specified by the index. * * @param r */ /* pre: // // Delete the given room record from the given RoomDB. The given room // must already be in the input db. // rooms.contains(r); post: // // A room is in the output data if and only if it is the new // record to be added or it is in the input data. // forall ( Room r_other ; rooms'.contains(r_other) iff !r_other.equals(r) && rooms.contains(r_other)); */ public abstract void removeRoom(Room r); /** * Returns sorted list of Rooms. */ /* post: // // The output list is sorted lexicographically by name of // Room, according to the semantics of // java.lang.String.compareto(). // forall (int i; (i>=0) && (i < return.size() - 1); return.get(i).building.buildingNumber.compareTo(return.get(i + 1).building.buildingNumber) < 0); */ public abstract List viewRooms(); }