The bug found in the presentation that we forgot to review has been fixed
[RRRRHHHH_Code] / ruralHouses / src / businessLogic / AdminManager.java
index a7e3a2a..0d8d152 100644 (file)
@@ -18,9 +18,6 @@ public class AdminManager extends UnicastRemoteObject implements AdminInterface
         */
        private static final long serialVersionUID = 1L;
 
-
-
-
        public AdminManager() throws RemoteException {
 
        }
@@ -39,8 +36,8 @@ public class AdminManager extends UnicastRemoteObject implements AdminInterface
                return new Vector<Account>(Administrator.getInstance()
                                .getNewOwnerRequest());
        }
-       
-       public Vector<Owner> getAllOwners()throws RemoteException {
+
+       public Vector<Owner> getAllOwners() throws RemoteException {
                try {
                        return new Vector<Owner>(DB4oManager.getInstance().getOwners());
                } catch (Exception e) {
@@ -48,20 +45,26 @@ public class AdminManager extends UnicastRemoteObject implements AdminInterface
                }
                return null;
        }
-       public void removeHouseAdditionRequests(RuralHouse house) throws RemoteException {
+
+       public void removeHouseAdditionRequests(RuralHouse house)
+                       throws RemoteException {
                Administrator.getInstance().getAddRequest().remove(house);
        }
 
-       public void removeHouseDeletionRequests(RuralHouse house) throws RemoteException {
+       public void removeHouseDeletionRequests(RuralHouse house)
+                       throws RemoteException {
                Administrator.getInstance().getRemoveRequest().remove(house);
        }
-       
+
        public void removeOwnerAdditionRequests(int index) throws RemoteException {
                Administrator.getInstance().getNewOwnerRequest().remove(index);
        }
-       
+
        public boolean addAdditionRequest(RuralHouse rh) throws RemoteException {
-               if (this.getAdditionRequests().contains(rh)) {
+               if (this.getAdditionRequests().contains(rh)
+                               || !suitsRegulations(rh.getFeatures().getnKitchens(), rh
+                                               .getFeatures().getnBaths(),rh
+                                               .getFeatures().getnLivings())) {
                        return false;
                }
                return Administrator.getInstance().getAddRequest().add(rh);
@@ -75,11 +78,11 @@ public class AdminManager extends UnicastRemoteObject implements AdminInterface
                return Administrator.getInstance().getRemoveRequest().add(rh);
 
        }
-       
-       public boolean addAccountRequest(String usr,
-                       String pss, Owner ow) throws RemoteException {
-               
-               Account acc = new Account (usr, pss,  ow);
+
+       public boolean addAccountRequest(String usr, String pss, Owner ow)
+                       throws RemoteException {
+
+               Account acc = new Account(usr, pss, ow);
                if (this.getOwnerAdditionRequests().contains(acc)) {
                        return false;
                }
@@ -89,15 +92,19 @@ public class AdminManager extends UnicastRemoteObject implements AdminInterface
        @Override
        public void saveInstance() throws RemoteException {
                Administrator.saveInstance();
-               
-       }
-
 
+       }
 
+       private boolean suitsRegulations(int nKitchens, int nBaths, int nLivings) {
+               if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
+                       return false;
+               else
+                       return true;
+       }
 
-//     public boolean removeAccount(Account acc) {
-//             if (this.getDeletionRequests().contains(acc))
-//                     return false;
-//             return Administrator.getInstance().getNewOwnerRequest().add(acc);
-//     }
+       // public boolean removeAccount(Account acc) {
+       // if (this.getDeletionRequests().contains(acc))
+       // return false;
+       // return Administrator.getInstance().getNewOwnerRequest().add(acc);
+       // }
 }