/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/30 10:46:15*/ /*This class drives: Booking*/ package hotel.core; import java.util.*; import java.sql.Time; import hotel.*; import hotel.json.*; public class RentableSpace { //Class datatypes private String costPerDay; private String floorArea; //Class association variables private Hotel hotel; private List bookings; private Suite suite; //Registry of our system. HotelRegistry registry = HotelRegistry.getInstance(); //Constructor public RentableSpace(String aCostPerDay, String aFloorArea, Hotel aHotel, Suite aSuite) { costPerDay = aCostPerDay; floorArea = aFloorArea; hotel = aHotel; hotel.addRentableSpace(this); bookings = new ArrayList(); registry.add(bookings); suite = aSuite; suite.addRentableSpace(this); } public boolean setCostPerDay(String aCostPerDay) { costPerDay = aCostPerDay; return true; } public boolean setFloorArea(String aFloorArea) { floorArea = aFloorArea; return true; } public String getCostPerDay() { return costPerDay; } public String getFloorArea() { return floorArea; } public Hotel getHotel() { return hotel; } public List getBookings() { return bookings; } public Suite getSuite() { return suite; } public Booking addBooking(String aStartDate, String aEndDate, String aStartTime, String aEndTime, String aBedroomsRequired, String aCreditCardToBill, Booking aBooking, Person aPerson) { Booking newBooking; newBooking = new Booking(aStartDate, aEndDate, aStartTime, aEndTime, aBedroomsRequired, aCreditCardToBill, aBooking, aPerson); if (!bookings.contains(newBooking)) { registry.add(newBooking); bookings.add(newBooking); } return newBooking; } public Booking addBooking(Booking aBooking) { if (!bookings.contains(aBooking)) bookings.add(aBooking); return aBooking; } /* This class does not drive Hotel and therefore sets the association unidirectionally.*/ public void setHotel(Hotel aHotel) { hotel = aHotel; } /* This class does not drive Suite and therefore sets the association unidirectionally.*/ public void setSuite(Suite aSuite) { suite = aSuite; } public void delete() { //Delete all many ends first. for (Booking aBooking : bookings) { aBooking.delete(); } bookings.clear(); //Delete all 1 ends. hotel.deleteRentableSpace(this); suite.deleteRentableSpace(this); } public void deleteBooking(Booking aBooking) { if (bookings.contains(aBooking)) { bookings.remove(aBooking); //registry.removeObj(registry.getKey(aBooking)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (bookings.size() == 0) { return true; } else return false; } /*********************************** * Returns the attribute list along with the * class ID in JSON format. ***********************************/ public JSONObject getAttributes() throws JSONException { JSONObject obj = new JSONObject(); obj.put("CLASS_ID", registry.getKey(this)); obj.put("costPerDay", getCostPerDay()); obj.put("floorArea", getFloorArea()); return obj; } }