Git Repository Public Repository

RRRRHHHH_Code

URLs

Copy to Clipboard

Diff Revisions 8012b0 ... vs 076d76 ... for ruralHouses/src/businessLogic/AdminManager.java

Diff revisions: vs.
  @@ -18,9 +18,6 @@
18 18 */
19 19 private static final long serialVersionUID = 1L;
20 20
21 -
22 -
23 -
24 21 public AdminManager() throws RemoteException {
25 22
26 23 }
  @@ -39,8 +36,8 @@
39 36 return new Vector<Account>(Administrator.getInstance()
40 37 .getNewOwnerRequest());
41 38 }
42 -
43 - public Vector<Owner> getAllOwners()throws RemoteException {
39 +
40 + public Vector<Owner> getAllOwners() throws RemoteException {
44 41 try {
45 42 return new Vector<Owner>(DB4oManager.getInstance().getOwners());
46 43 } catch (Exception e) {
  @@ -48,20 +45,26 @@
48 45 }
49 46 return null;
50 47 }
51 - public void removeHouseAdditionRequests(RuralHouse house) throws RemoteException {
48 +
49 + public void removeHouseAdditionRequests(RuralHouse house)
50 + throws RemoteException {
52 51 Administrator.getInstance().getAddRequest().remove(house);
53 52 }
54 53
55 - public void removeHouseDeletionRequests(RuralHouse house) throws RemoteException {
54 + public void removeHouseDeletionRequests(RuralHouse house)
55 + throws RemoteException {
56 56 Administrator.getInstance().getRemoveRequest().remove(house);
57 57 }
58 -
58 +
59 59 public void removeOwnerAdditionRequests(int index) throws RemoteException {
60 60 Administrator.getInstance().getNewOwnerRequest().remove(index);
61 61 }
62 -
62 +
63 63 public boolean addAdditionRequest(RuralHouse rh) throws RemoteException {
64 - if (this.getAdditionRequests().contains(rh)) {
64 + if (this.getAdditionRequests().contains(rh)
65 + || !suitsRegulations(rh.getFeatures().getnKitchens(), rh
66 + .getFeatures().getnBaths(),rh
67 + .getFeatures().getnLivings())) {
65 68 return false;
66 69 }
67 70 return Administrator.getInstance().getAddRequest().add(rh);
  @@ -75,11 +78,11 @@
75 78 return Administrator.getInstance().getRemoveRequest().add(rh);
76 79
77 80 }
78 -
79 - public boolean addAccountRequest(String usr,
80 - String pss, Owner ow) throws RemoteException {
81 -
82 - Account acc = new Account (usr, pss, ow);
81 +
82 + public boolean addAccountRequest(String usr, String pss, Owner ow)
83 + throws RemoteException {
84 +
85 + Account acc = new Account(usr, pss, ow);
83 86 if (this.getOwnerAdditionRequests().contains(acc)) {
84 87 return false;
85 88 }
  @@ -89,15 +92,19 @@
89 92 @Override
90 93 public void saveInstance() throws RemoteException {
91 94 Administrator.saveInstance();
92 -
93 - }
94 -
95 95
96 + }
96 97
98 + private boolean suitsRegulations(int nKitchens, int nBaths, int nLivings) {
99 + if (nKitchens < 1 || nLivings < 3 || nBaths < 2)
100 + return false;
101 + else
102 + return true;
103 + }
97 104
98 - // public boolean removeAccount(Account acc) {
99 - // if (this.getDeletionRequests().contains(acc))
100 - // return false;
101 - // return Administrator.getInstance().getNewOwnerRequest().add(acc);
102 - // }
105 + // public boolean removeAccount(Account acc) {
106 + // if (this.getDeletionRequests().contains(acc))
107 + // return false;
108 + // return Administrator.getInstance().getNewOwnerRequest().add(acc);
109 + // }
103 110 }