no warnings
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / BookingManager.java
index 18670e1..b9fa7bd 100644 (file)
@@ -1,9 +1,14 @@
 package businessLogic;
 
+import java.util.Date;
+
 import com.db4o.ObjectContainer;
 import com.db4o.ObjectSet;
 
 import dataAccess.DB4oManager;
+import domain.Booking;
+import domain.RuralHouse;
+import exceptions.OfferCanNotBeBooked;
 
 
 public final class BookingManager {
@@ -13,7 +18,13 @@ public final class BookingManager {
 
        private static BookingManager theBookingManager;
 
-       private BookingManager() {}
+       public BookingManager() {
+               try {
+                       this.dbMngr = DB4oManager.getInstance();
+               } catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
        
        /**
         * This method returns the next Booking number 
@@ -37,7 +48,7 @@ public final class BookingManager {
        public static BookingManager getInstance()  {
                ObjectContainer db=DB4oManager.getContainer();
            BookingManager b = new BookingManager();
-           ObjectSet result = db.queryByExample(b);
+           ObjectSet<BookingManager> result = db.queryByExample(b);
            if (!result.hasNext()){
                theBookingManager = new BookingManager();
                db.store(theBookingManager);
@@ -46,4 +57,17 @@ public final class BookingManager {
                return theBookingManager;
        }
        
+       /**
+        * This method creates a book with a corresponding parameters
+        * 
+        * @param First
+        *            day, last day, house number and telephone
+        * @return a book
+        */
+       public Booking createBooking(RuralHouse ruralHouse, Date firstDate, Date lastDate, String bookTelephoneNumber)
+                       throws OfferCanNotBeBooked {
+
+               return dbMngr.createBooking(ruralHouse,firstDate,lastDate,bookTelephoneNumber);
+       }
+       
 }
\ No newline at end of file