The code for different owner operations mostly implemented
authorunknown <jcampos004@ikasle.ehu.es>
Tue, 3 Mar 2015 22:07:56 +0000 (23:07 +0100)
committerunknown <jcampos004@ikasle.ehu.es>
Tue, 3 Mar 2015 22:07:56 +0000 (23:07 +0100)
13 files changed:
ruralHouses/db/DBjcampos004.yap [deleted file]
ruralHouses/src/businessLogic/ApplicationFacadeInterface.java
ruralHouses/src/businessLogic/FacadeImplementation.java
ruralHouses/src/businessLogic/HouseManager.java [new file with mode: 0644]
ruralHouses/src/businessLogic/HouseManagerInterface.java [new file with mode: 0644]
ruralHouses/src/businessLogic/LoginManager.java
ruralHouses/src/dataAccess/DB4oManager.java
ruralHouses/src/domain/HouseFeatures.java [new file with mode: 0644]
ruralHouses/src/domain/Owner.java
ruralHouses/src/domain/RuralHouse.java
ruralHouses/src/gui/BookRuralHouseGUI.java
ruralHouses/src/gui/IntroduceOfferGUI.java
ruralHouses/src/gui/StartWindow.java

diff --git a/ruralHouses/db/DBjcampos004.yap b/ruralHouses/db/DBjcampos004.yap
deleted file mode 100644 (file)
index 34e1d5a..0000000
Binary files a/ruralHouses/db/DBjcampos004.yap and /dev/null differ
index 215e60b..8863af3 100644 (file)
@@ -68,6 +68,4 @@ public interface ApplicationFacadeInterface extends Remote {
        public Vector<RuralHouse> getAllRuralHouses()throws RemoteException,
        Exception;
        
        public Vector<RuralHouse> getAllRuralHouses()throws RemoteException,
        Exception;
        
-       public void close() throws RemoteException;
-       
 }
\ No newline at end of file
 }
\ No newline at end of file
index c4670bb..162a38b 100644 (file)
@@ -75,9 +75,7 @@ public class FacadeImplementation extends UnicastRemoteObject implements Applica
                return dbMngr.getAllRuralHouses();              
        }
 
                return dbMngr.getAllRuralHouses();              
        }
 
-       public void close() throws RemoteException{
-               DB4oManager.close();
-       }
+       
 
        public Booking createBooking(RuralHouse ruralHouse, Date firstDate, Date lastDate, String bookTelephoneNumber)
                        throws OfferCanNotBeBooked {
 
        public Booking createBooking(RuralHouse ruralHouse, Date firstDate, Date lastDate, String bookTelephoneNumber)
                        throws OfferCanNotBeBooked {
@@ -90,7 +88,10 @@ public class FacadeImplementation extends UnicastRemoteObject implements Applica
                        exc.printStackTrace();
                        return null;
                }
                        exc.printStackTrace();
                        return null;
                }
+               
        }
 
        }
 
+       
+
 }
 
 }
 
diff --git a/ruralHouses/src/businessLogic/HouseManager.java b/ruralHouses/src/businessLogic/HouseManager.java
new file mode 100644 (file)
index 0000000..a876bcd
--- /dev/null
@@ -0,0 +1,81 @@
+package businessLogic;
+
+import java.util.Date;
+import java.util.Vector;
+
+import dataAccess.DB4oManager;
+import domain.Account;
+import domain.Offer;
+import domain.Owner;
+import domain.RuralHouse;
+
+public class HouseManager implements HouseManagerInterface {
+       DB4oManager dbMngr;
+
+       public HouseManager() {
+               try {
+                       dbMngr = DB4oManager.getInstance();
+               } catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+       }
+
+       @Override
+       public boolean registerNewHouse(int houseNumber, Owner owner, String town,
+                       int nRooms, int nKitchens, int nBaths, int nLivings, int nParkings) {
+               // TODO Auto-generated method stub
+               if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
+                       return false;
+               try {
+                       this.dbMngr.storeRuralHouses(new RuralHouse(houseNumber, owner,
+                                       town, nRooms, nKitchens, nBaths, nLivings, nParkings));
+               } catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+               return true;
+
+       }
+
+       @Override
+       public boolean registerNewHouse(int houseNumber, Owner owner,
+                       String description, String town, int nRooms, int nKitchens,
+                       int nBaths, int nLivings, int nParkings) {
+               // TODO Auto-generated method stub
+               if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
+                       return false;
+               try {
+                       this.dbMngr.storeRuralHouses(new RuralHouse(houseNumber, owner,
+                                       description, town, nRooms, nKitchens, nBaths, nLivings,
+                                       nParkings));
+               } catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+               return true;
+       }
+
+       @Override
+       public void modifyHouse(int houseNumber, Owner owner, String description,
+                       String town, int nRooms, int nKitchens, int nBaths, int nLivings,
+                       int nParkings) {
+               // TODO Auto-generated method stub
+               
+       }
+       
+       //Maybe returning the offer is not necessary. Depends on GUI implementation.
+       @Override
+       public Offer setOffers(RuralHouse ruralHouse, Date firstDay, Date lastDay,
+                       float price) {
+               // TODO Auto-generated method stub
+               try {
+                       return this.dbMngr.createOffer(ruralHouse, firstDay, lastDay, price);
+               } catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }
+               return null;
+       }
+
+}
diff --git a/ruralHouses/src/businessLogic/HouseManagerInterface.java b/ruralHouses/src/businessLogic/HouseManagerInterface.java
new file mode 100644 (file)
index 0000000..29c97d5
--- /dev/null
@@ -0,0 +1,25 @@
+package businessLogic;
+
+import java.util.Date;
+
+import domain.Offer;
+import domain.Owner;
+import domain.RuralHouse;
+
+public interface HouseManagerInterface {
+
+       public boolean registerNewHouse(int houseNumber, Owner owner, String town,
+                       int nRooms, int nKitchens, int nBaths, int nLivings, int nParkings);
+
+       public boolean registerNewHouse(int houseNumber, Owner owner,
+                       String description, String town, int nRooms, int nKitchens,
+                       int nBaths, int nLivings, int nParkings);
+
+       public void modifyHouse(int houseNumber, Owner owner,
+                       String description, String town, int nRooms, int nKitchens,
+                       int nBaths, int nLivings, int nParkings);
+
+       public Offer setOffers(RuralHouse ruralHouse, Date firstDay, Date lastDay,
+                       float price);
+
+}
index da6078b..966168c 100644 (file)
@@ -1,8 +1,5 @@
 package businessLogic;
 
 package businessLogic;
 
-import gui.StartWindow;
-
-import java.rmi.RemoteException;
 import java.util.Vector;
 
 import dataAccess.DB4oManager;
 import java.util.Vector;
 
 import dataAccess.DB4oManager;
@@ -10,12 +7,11 @@ import domain.Account;
 import domain.Owner;
 
 public class LoginManager implements LoginManagerInterface {
 import domain.Owner;
 
 public class LoginManager implements LoginManagerInterface {
-       //owners to be separated to accounts later on
+
        DB4oManager dbMngr;
        DB4oManager dbMngr;
-       
-       
+
        public LoginManager() {
        public LoginManager() {
-               
+
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
                try {
                        dbMngr = DB4oManager.getInstance();
                } catch (Exception e) {
@@ -24,21 +20,20 @@ public class LoginManager implements LoginManagerInterface {
                }
        }
 
                }
        }
 
-
        @Override
        public Owner checkCredentials(String usr, String pwd) {
                try {
                        Vector<Account> account = dbMngr.getAccount(usr, pwd);
        @Override
        public Owner checkCredentials(String usr, String pwd) {
                try {
                        Vector<Account> account = dbMngr.getAccount(usr, pwd);
-                       if(account.isEmpty()) return null;
-                       else return account.get(0).getOwner();
-                       
+                       if (account.isEmpty())
+                               return null;
+                       else
+                               return account.get(0).getOwner();
+
                } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                return null;
        }
                } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                return null;
        }
-       
-       
-        
+
 }
 }
index 6d55e8d..295af73 100644 (file)
@@ -7,7 +7,6 @@ import java.util.Vector;
 //import java.util.Enumeration;
 //import java.util.Vector;
 
 //import java.util.Enumeration;
 //import java.util.Vector;
 
-
 import businessLogic.BookingManager;
 
 import com.db4o.*;
 import businessLogic.BookingManager;
 
 import com.db4o.*;
@@ -16,146 +15,209 @@ import configuration.Config;
 import domain.*;
 import exceptions.OfferCanNotBeBooked;
 
 import domain.*;
 import exceptions.OfferCanNotBeBooked;
 
-public class DB4oManager { 
+public class DB4oManager {
 
        private static ObjectContainer db;
 
        private static ObjectContainer db;
-       private static DB4oManager theDB4oManager=new DB4oManager();
+       private static DB4oManager theDB4oManager = new DB4oManager();
 
 
+       /**
+        * 
+        */
        private DB4oManager() {
        private DB4oManager() {
-               Config c=Config.getInstance();
-               String dataBaseOpenMode=c.getDataBaseOpenMode();
+               Config c = Config.getInstance();
+               String dataBaseOpenMode = c.getDataBaseOpenMode();
                DB4oManager.openDatabase(dataBaseOpenMode);
        }
 
                DB4oManager.openDatabase(dataBaseOpenMode);
        }
 
+       /**
+        * @param mode
+        */
        public static void openDatabase(String mode) {
        public static void openDatabase(String mode) {
-               Config c=Config.getInstance();
-               String db4oFileName=c.getDb4oFilename();
-               if (mode.compareTo("open")==0) {
-                       db=Db4o.openFile(Db4o.newConfiguration(), db4oFileName);
+               Config c = Config.getInstance();
+               String db4oFileName = c.getDb4oFilename();
+               if (mode.compareTo("open") == 0) {
+                       db = Db4o.openFile(Db4o.newConfiguration(), db4oFileName);
                        db.ext().configure().updateDepth(5);
                        db.ext().configure().updateDepth(5);
-                       System.out.println("DataBase Opened");
 
 
-               } else if (mode.compareTo("initialize")==0){
-                       new File(db4oFileName).delete();
-                       db=Db4o.openFile(Db4o.newConfiguration(), db4oFileName);
-                       db.ext().configure().updateDepth(5);
-                       Owner jon = new Owner("Jon");
-                       Owner alfredo = new Owner("Alfredo");
-                       jon.addRuralHouse(1, "Ezkioko etxea","Ezkio");
-                       jon.addRuralHouse(2, "Eskiatzeko etxea","Jaca");
-                       jon.setBankAccount("1349 5677 21 2133567777");
-                       alfredo.addRuralHouse(3, "Casa del abuelo","Pitillas");
-                       alfredo.addRuralHouse(4, "Refugio","Murgia");
-                       alfredo.setBankAccount("4144 0087 23 9700002133");
-                       Account jonAcc = new Account("userJon", "passJon",jon);
-                       Account alfredoAcc = new Account("userAlfredo", "passAlfredo",alfredo);
-                       db.store(jon);
-                       db.store(alfredo);
-                       db.store(jonAcc);
-                       db.store(alfredoAcc);
-                       db.commit();
-                       System.out.println("DataBase Initialized");
+               } else if (mode.compareTo("initialize") == 0) {
+                       try {
+                               new File(db4oFileName).delete();
+                               db = Db4o.openFile(Db4o.newConfiguration(), db4oFileName);
+                               db.ext().configure().updateDepth(5);
+                               Owner jon = new Owner("Jon");
+                               Owner alfredo = new Owner("Alfredo");
+                               jon.addRuralHouse(1, "Ezkioko etxea", "Ezkio", 3, 3, 3, 3, 3);
+                               jon.addRuralHouse(2, "Eskiatzeko etxea", "Jaca", 4, 4, 4, 4, 4);
+                               jon.setBankAccount("1349 5677 21 2133567777");
+                               alfredo.addRuralHouse(3, "Casa del abuelo", "Pitillas", 5, 5,
+                                               5, 5, 5);
+                               alfredo.addRuralHouse(4, "Murgia", 6, 6, 6, 6, 6);
+                               alfredo.setBankAccount("4144 0087 23 9700002133");
+                               Account jonAcc = new Account("userJon", "passJon", jon);
+                               Account alfredoAcc = new Account("userAlfredo", "passAlfredo",
+                                               alfredo);
+                               db.store(jon);
+                               db.store(alfredo);
+                               db.store(jonAcc);
+                               db.store(alfredoAcc);
+                               db.commit();
+                               System.out.println("DataBase Initialized");
+                       } finally {
+                               db.close();
+                       }
+
                }
        }
 
                }
        }
 
-       public  static ObjectContainer getContainer() {
+       /**
+        * @return
+        */
+       public static ObjectContainer getContainer() {
                return db;
        }
                return db;
        }
-       public static void close(){
-               db.close();
-               System.out.println("DataBase closed");
+
+       /**
+        * @param rh
+        */
+       public void storeRuralHouses(RuralHouse rh) {
+               DB4oManager.openDatabase("open");
+               ObjectContainer db = DB4oManager.getContainer();
+               try {
+                       db.store(rh);
+                       db.commit();
+               } finally {
+                       db.close();
+               }
        }
        }
-       
+
        /**
        /**
-        * This method finds all existing  owners 
+        * This method finds all existing owners
         * 
         */
         * 
         */
-       public Vector<Owner> getOwners() throws RemoteException,
-       Exception {
-               ObjectContainer db=DB4oManager.getContainer();
+       public Vector<Owner> getOwners() throws RemoteException, Exception {
+               DB4oManager.openDatabase("open");
+               ObjectContainer db = DB4oManager.getContainer();
 
                try {
 
                try {
-                       Owner proto = new Owner(null,null);
-                       ObjectSet result = db.queryByExample(proto);
-                       Vector<Owner> owners=new Vector<Owner>();
-                       while(result.hasNext())                          
-                               owners.add((Owner)result.next());
+                       Owner proto = new Owner(null, null);
+                       ObjectSet<Owner> result = db.queryByExample(proto);
+                       Vector<Owner> owners = new Vector<Owner>();
+                       while (result.hasNext())
+                               owners.add((Owner) result.next());
                        return owners;
                } finally {
                        return owners;
                } finally {
-                       //db.close();
+                       db.close();
                }
                }
-       } 
-       
-       public Vector<Account> getAccount(String usr, String pwd) throws RemoteException,
-       Exception {
-               ObjectContainer db=DB4oManager.getContainer();
+       }
+
+       /**
+        * @param usr
+        * @param pwd
+        * @return
+        * @throws RemoteException
+        * @throws Exception
+        */
+       public Vector<Account> getAccount(String usr, String pwd)
+                       throws RemoteException, Exception {
+               DB4oManager.openDatabase("open");
+               ObjectContainer db = DB4oManager.getContainer();
 
                try {
 
                try {
-                       Account proto = new Account(usr,pwd, new Owner(null,null));
-                       ObjectSet result = db.queryByExample(proto);
-                       Vector<Account> accounts=new Vector<Account>();
-                       while(result.hasNext())                          
-                               accounts.add((Account)result.next());
+                       Account proto = new Account(usr, pwd, new Owner(null, null));
+                       ObjectSet<Account> result = db.queryByExample(proto);
+                       Vector<Account> accounts = new Vector<Account>();
+                       while (result.hasNext())
+                               accounts.add((Account) result.next());
                        return accounts;
                } finally {
                        return accounts;
                } finally {
-                       //db.close();
+                       db.close();
                }
        }
                }
        }
-       
+
+       /**
+        * @return
+        * @throws RemoteException
+        * @throws Exception
+        */
        public Vector<RuralHouse> getAllRuralHouses() throws RemoteException,
        public Vector<RuralHouse> getAllRuralHouses() throws RemoteException,
-       Exception {
-               ObjectContainer db=DB4oManager.getContainer();
+                       Exception {
+               DB4oManager.openDatabase("open");
+               ObjectContainer db = DB4oManager.getContainer();
                try {
                try {
-                       RuralHouse proto = new RuralHouse(0,null,null,null);
-                       ObjectSet result = db.queryByExample(proto);
-                       Vector<RuralHouse> ruralHouses=new Vector<RuralHouse>();
-                       while(result.hasNext()) 
-                               ruralHouses.add((RuralHouse)result.next());
+                       RuralHouse proto = new RuralHouse(0, null, null, null, 0, 0, 0, 0,
+                                       0);
+                       ObjectSet<RuralHouse> result = db.queryByExample(proto);
+                       Vector<RuralHouse> ruralHouses = new Vector<RuralHouse>();
+                       while (result.hasNext())
+                               ruralHouses.add((RuralHouse) result.next());
                        return ruralHouses;
                } finally {
                        return ruralHouses;
                } finally {
-                       //db.close();
+                       db.close();
                }
        }
 
        /**
                }
        }
 
        /**
-        * This method creates an offer with a house number, first day, last day and price
-        * precondition: There are no overlapping offers
+        * This method creates an offer with a house number, first day, last day and
+        * price precondition: There are no overlapping offers
+        * 
         * @param House
         *            number, start day, last day and price
         * @return None
         */
         * @param House
         *            number, start day, last day and price
         * @return None
         */
-       public Offer createOffer(RuralHouse ruralHouse, Date firstDay, Date lastDay,
-                       float price) throws RemoteException, Exception {
-               ObjectContainer db=DB4oManager.getContainer();
-               RuralHouse proto = new RuralHouse(ruralHouse.getHouseNumber(), null, 
-                               ruralHouse.getDescription(), ruralHouse.getTown());
-               ObjectSet result = db.queryByExample(proto);
-               RuralHouse rh=(RuralHouse)result.next();
-               Offer o=rh.createOffer(firstDay, lastDay, price);
-               db.store(o);
-               db.commit(); 
+       public Offer createOffer(RuralHouse ruralHouse, Date firstDay,
+                       Date lastDay, float price) throws RemoteException, Exception {
+               DB4oManager.openDatabase("open");
+               ObjectContainer db = DB4oManager.getContainer();
+               Offer o;
+               try {
+                       RuralHouse proto = new RuralHouse(ruralHouse.getHouseNumber(),
+                                       null, ruralHouse.getDescription(), ruralHouse.getTown(), 0,
+                                       0, 0, 0, 0);
+                       ObjectSet<RuralHouse> result = db.queryByExample(proto);
+                       RuralHouse rh = (RuralHouse) result.next();
+                       o = rh.createOffer(firstDay, lastDay, price);
+                       db.store(o);
+                       db.commit();
+               } finally {
+                       db.close();
+               }
                return o;
        }
 
                return o;
        }
 
-       public RuralHouse getRuralHouse(RuralHouse rh){
+       /**
+        * @param rh
+        * @return
+        */
+       public RuralHouse getRuralHouse(RuralHouse rh) {
+
+               DB4oManager.openDatabase("open");
                try {
                try {
-                       ObjectContainer db=DB4oManager.getContainer();
+                       ObjectContainer db = DB4oManager.getContainer();
                        RuralHouse proto = new RuralHouse(rh.getHouseNumber(), null,
                        RuralHouse proto = new RuralHouse(rh.getHouseNumber(), null,
-                                       rh.getDescription(), rh.getTown());
-                       ObjectSet result = db.queryByExample(proto);
-                       return  rh=(RuralHouse)result.next();
+                                       rh.getDescription(), rh.getTown(), 0, 0, 0, 0, 0);
+                       ObjectSet<RuralHouse> result = db.queryByExample(proto);
+                       return rh = (RuralHouse) result.next();
                } catch (Exception exc) {
                        exc.printStackTrace();
                        return null;
                } catch (Exception exc) {
                        exc.printStackTrace();
                        return null;
+               } finally {
+                       db.close();
                }
        }
 
                }
        }
 
+       /**
+        * @param offer
+        * @param clientTelephoneNumber
+        * @return
+        * @throws OfferCanNotBeBooked
+        */
        public Booking createBooking(Offer offer, String clientTelephoneNumber)
                        throws OfferCanNotBeBooked {
        public Booking createBooking(Offer offer, String clientTelephoneNumber)
                        throws OfferCanNotBeBooked {
+               DB4oManager.openDatabase("open");
                try {
                try {
-                       Booking b=null;
-                       if (offer!=null) {
-                               b=offer.createBook(clientTelephoneNumber);
+                       Booking b = null;
+                       if (offer != null) {
+                               b = offer.createBook(clientTelephoneNumber);
                                db.store(b);
                                db.store(offer);
                                db.commit();
                                db.store(b);
                                db.store(offer);
                                db.commit();
@@ -164,17 +226,18 @@ public class DB4oManager {
                } catch (Exception exc) {
                        exc.printStackTrace();
                        return null;
                } catch (Exception exc) {
                        exc.printStackTrace();
                        return null;
+               } finally {
+                       db.close();
                }
        }
 
        /**
                }
        }
 
        /**
-        * This method returns the instance of the DB4oManager class 
+        * This method returns the instance of the DB4oManager class
         * 
         * @return the db4o manager
         */
         * 
         * @return the db4o manager
         */
-       public static DB4oManager getInstance()  {
+       public static DB4oManager getInstance() {
                return theDB4oManager;
        }
 
 }
                return theDB4oManager;
        }
 
 }
-
diff --git a/ruralHouses/src/domain/HouseFeatures.java b/ruralHouses/src/domain/HouseFeatures.java
new file mode 100644 (file)
index 0000000..c26de8a
--- /dev/null
@@ -0,0 +1,21 @@
+package domain;
+
+public class HouseFeatures {
+
+       private int nRooms;
+       private int nKitchens;
+       private int nBaths;
+       private int nLivings;
+       private int nParkings;
+
+       public HouseFeatures(int nRooms, int nKitchens, int nBaths, int nLivings,
+                       int nParkings) {
+               super();
+               this.nRooms = nRooms;
+               this.nKitchens = nKitchens;
+               this.nBaths = nBaths;
+               this.nLivings = nLivings;
+               this.nParkings = nParkings;
+       }
+
+}
index 35f390c..9a34067 100644 (file)
@@ -7,18 +7,18 @@ import java.util.Vector;
 public class Owner implements Serializable {
 
        private String bankAccount = "";
 public class Owner implements Serializable {
 
        private String bankAccount = "";
-       private String name="";
+       private String name = "";
        private Vector<RuralHouse> ruralHouses;
 
        public Owner(String name) {
        private Vector<RuralHouse> ruralHouses;
 
        public Owner(String name) {
-               this.name=name;
-               ruralHouses=new Vector<RuralHouse>();           
+               this.name = name;
+               ruralHouses = new Vector<RuralHouse>();
        }
 
        public Owner(String name, String bankAccount) {
        }
 
        public Owner(String name, String bankAccount) {
-               this.bankAccount=bankAccount;
-               this.name=name;
-               ruralHouses=new Vector<RuralHouse>();           
+               this.bankAccount = bankAccount;
+               this.name = name;
+               ruralHouses = new Vector<RuralHouse>();
        }
 
        public String getName() {
        }
 
        public String getName() {
@@ -41,13 +41,24 @@ public class Owner implements Serializable {
                return ruralHouses;
        }
 
                return ruralHouses;
        }
 
-       public RuralHouse addRuralHouse(int houseNumber, String description, String city) {
-               RuralHouse rh=new RuralHouse(houseNumber,  this,  description,  city);
+       public RuralHouse addRuralHouse(int houseNumber, String town, int nRooms,
+                       int nKitchens, int nBaths, int nLivings, int nParkings) {
+               RuralHouse rh = new RuralHouse(houseNumber, this, town, nRooms,
+                               nKitchens, nBaths, nLivings, nParkings);
+               ruralHouses.add(rh);
+               return rh;
+       }
+
+       public RuralHouse addRuralHouse(int houseNumber, String description,
+                       String town, int nRooms, int nKitchens, int nBaths, int nLivings,
+                       int nParkings) {
+               RuralHouse rh = new RuralHouse(houseNumber, this, description, town,
+                               nRooms, nKitchens, nBaths, nLivings, nParkings);
                ruralHouses.add(rh);
                return rh;
        }
                ruralHouses.add(rh);
                return rh;
        }
-       
-       public String toString(){
+
+       public String toString() {
                return name;
        }
 
                return name;
        }
 
index 13a751d..d499c88 100644 (file)
@@ -13,17 +13,30 @@ public class RuralHouse implements Serializable {
        private String description;
        private Owner owner;
        private String town; 
        private String description;
        private Owner owner;
        private String town; 
+       private HouseFeatures features;
        public Vector<Offer> offers;
        
        public RuralHouse() {
                super();
        }
 
        public Vector<Offer> offers;
        
        public RuralHouse() {
                super();
        }
 
-       public RuralHouse(int houseNumber, Owner owner, String description, String town) {
+       public RuralHouse(int houseNumber, Owner owner, String description, String town , int nRooms,int nKitchens,int nBaths, 
+                       int nLivings,int nParkings) {
                this.houseNumber = houseNumber;
                this.description = description;
                this.owner = owner;
                this.town = town;
                this.houseNumber = houseNumber;
                this.description = description;
                this.owner = owner;
                this.town = town;
+               this.features = new HouseFeatures(nRooms,nKitchens,nBaths,nLivings,nParkings);
+               offers=new Vector<Offer>();
+       }
+       
+       public RuralHouse(int houseNumber, Owner owner, String town , int nRooms,int nKitchens,int nBaths, 
+                       int nLivings,int nParkings) {
+               this.houseNumber = houseNumber;
+               this.description = null;
+               this.owner = owner;
+               this.town = town;
+               this.features = new HouseFeatures(nRooms,nKitchens,nBaths,nLivings,nParkings);
                offers=new Vector<Offer>();
        }
 
                offers=new Vector<Offer>();
        }
 
@@ -140,5 +153,7 @@ public class RuralHouse implements Serializable {
                }
                return null;            
        }
                }
                return null;            
        }
+       
+       
 
 }
 
 }
index fead030..eadd8b0 100644 (file)
@@ -136,8 +136,8 @@ public class BookRuralHouseGUI extends JFrame {
                                        ApplicationFacadeInterface facade=StartWindow.getBusinessLogic();
 
                                        Booking book=facade.createBooking(house, firstDay, lastDay, telephone);
                                        ApplicationFacadeInterface facade=StartWindow.getBusinessLogic();
 
                                        Booking book=facade.createBooking(house, firstDay, lastDay, telephone);
-                                       System.out.println(book.getPrice());
                                        if (book!=null) {
                                        if (book!=null) {
+                                               System.out.println(book.getPrice());
                                                BookRuralHouseConfirmationWindow confirmWindow=new BookRuralHouseConfirmationWindow(book);
                                                confirmWindow.setVisible(true);
                                        }
                                                BookRuralHouseConfirmationWindow confirmWindow=new BookRuralHouseConfirmationWindow(book);
                                                confirmWindow.setVisible(true);
                                        }
index 8d34d9d..ee56946 100644 (file)
@@ -71,7 +71,7 @@ public class IntroduceOfferGUI extends JFrame {
                                                        e.printStackTrace();
                                                }
                                                if(!ownerHouseList.isEmpty()){
                                                        e.printStackTrace();
                                                }
                                                if(!ownerHouseList.isEmpty()){
-                                                       Frame a = new IntroduceOffer2GUI(ownerHouseList);                                                       
+                                                       Frame a = new IntroduceOffer2GUI(ownerHouseList);       
                                                        a.setVisible(true);
                                                }
                                                else if(ownerHouseList.isEmpty())
                                                        a.setVisible(true);
                                                }
                                                else if(ownerHouseList.isEmpty())
index 98b912e..f5e5b10 100644 (file)
@@ -122,11 +122,11 @@ public class StartWindow extends JFrame {
                                        //JFrame a = new QueryAvailabilityWindow();
                                        ApplicationFacadeInterface facade=StartWindow.facadeInterface;
                                        try {
                                        //JFrame a = new QueryAvailabilityWindow();
                                        ApplicationFacadeInterface facade=StartWindow.facadeInterface;
                                        try {
-                                               facade.close();
+                                               
                                                setVisible(false);
                                                System.exit(1);
                                        }
                                                setVisible(false);
                                                System.exit(1);
                                        }
-                                       catch (RemoteException e1) {
+                                       catch (Exception e1) {
                                                // TODO Auto-generated catch block
                                                e1.printStackTrace();
                                        }                                       
                                                // TODO Auto-generated catch block
                                                e1.printStackTrace();
                                        }                                       
@@ -160,7 +160,6 @@ public class StartWindow extends JFrame {
                        //System.out.println(e.toString());
                        e.printStackTrace();
                }
                        //System.out.println(e.toString());
                        e.printStackTrace();
                }
-               int x=0;
                JFrame a = new StartWindow();
                a.setVisible(true);
        }
                JFrame a = new StartWindow();
                a.setVisible(true);
        }