|
@@ -21,56 +21,38 @@ |
21 |
21 |
|
} |
22 |
22 |
|
|
23 |
23 |
|
|
24 |
|
- |
|
25 |
|
- |
@Override |
26 |
|
- |
public boolean registerNewHouse(String houseName, Owner owner, |
27 |
|
- |
String description, String district, int nRooms, int nKitchens, |
28 |
|
- |
int nBaths, int nLivings, int nParkings) { |
29 |
|
- |
|
30 |
|
- |
boolean stored = false; |
|
24 |
+ |
private boolean suitsRegulations(int nKitchens, int nBaths, int nLivings) { |
31 |
25 |
|
if (nKitchens < 1 || nLivings < 3 || nBaths < 2) |
32 |
26 |
|
return false; |
33 |
|
- |
HouseFeatures feature = new HouseFeatures(nRooms, nKitchens, nBaths, |
34 |
|
- |
nLivings, nParkings); |
35 |
|
- |
RuralHouse rh = new RuralHouse(houseName, |
36 |
|
- |
owner, description, district, feature); |
37 |
|
- |
owner.getRuralHouses().add(rh); |
38 |
|
- |
stored = this.dbMngr.storeRuralHouses(rh); |
39 |
|
- |
return stored; |
|
27 |
+ |
else |
|
28 |
+ |
return true; |
40 |
29 |
|
} |
41 |
|
- |
|
42 |
|
- |
@Override |
43 |
30 |
|
|
|
31 |
+ |
@Override |
44 |
32 |
|
public boolean registerNewHouse(RuralHouse rh) { |
45 |
|
- |
|
|
33 |
+ |
|
46 |
34 |
|
boolean stored = false; |
47 |
|
- |
|
|
35 |
+ |
if (!suitsRegulations(rh.getFeatures().getnKitchens(), rh.getFeatures() |
|
36 |
+ |
.getnBaths(), rh.getFeatures().getnKitchens())) |
|
37 |
+ |
return false; |
48 |
38 |
|
rh.getOwner().getRuralHouses().add(rh); |
49 |
39 |
|
stored = this.dbMngr.storeRuralHouses(rh); |
50 |
40 |
|
return stored; |
51 |
41 |
|
} |
52 |
|
- |
|
53 |
42 |
|
|
54 |
|
- |
public void removeHouse(RuralHouse rh , Owner owner) { |
55 |
|
- |
Vector<RuralHouse> temp = owner.getRuralHouses(); |
|
43 |
+ |
public void removeHouse(RuralHouse rh, Owner owner) { |
|
44 |
+ |
Vector<RuralHouse> temp = owner.getRuralHouses(); |
56 |
45 |
|
temp.remove(rh); |
57 |
46 |
|
this.dbMngr.removeHouse(rh, owner); |
58 |
47 |
|
} |
59 |
48 |
|
|
60 |
49 |
|
|
61 |
50 |
|
|
62 |
|
- |
@Override |
63 |
|
- |
public Vector<RuralHouse> getHousesByDistrict(String town) { |
64 |
|
- |
|
65 |
|
- |
return this.dbMngr.getRuralHousesByTown(town); |
66 |
|
- |
} |
67 |
|
- |
|
68 |
|
- |
public Vector<RuralHouse> getHouses(String town,int nBed , int nKit, int nBath, int nPark, int nLiv) { |
69 |
|
- |
|
70 |
|
- |
return this.dbMngr.getRuralHouses(town, nBed, nKit, nBath, nPark, nLiv); |
71 |
|
- |
} |
72 |
|
- |
|
|
51 |
+ |
public Vector<RuralHouse> getHouses(String name,String town, int nBed, int nKit, |
|
52 |
+ |
int nBath, int nPark, int nLiv) { |
73 |
53 |
|
|
|
54 |
+ |
return this.dbMngr.getRuralHouses(name ,town, nBed, nKit, nBath, nPark, nLiv); |
|
55 |
+ |
} |
74 |
56 |
|
|
75 |
57 |
|
@Override |
76 |
58 |
|
public Vector<RuralHouse> getAllRuralHouses() throws RemoteException, |
|
@@ -80,15 +62,6 @@ |
80 |
62 |
|
|
81 |
63 |
|
|
82 |
64 |
|
|
83 |
|
- |
@Override |
84 |
|
- |
public RuralHouse getHouseByName(String Name) { |
85 |
|
- |
return this.dbMngr.getRuralHouseByName(Name); |
86 |
|
- |
} |
87 |
|
- |
|
88 |
|
- |
|
89 |
|
- |
|
90 |
|
- |
|
91 |
|
- |
|
92 |
65 |
|
// For future implementation |
93 |
66 |
|
// @Override |
94 |
67 |
|
// public void modifyHouse(int houseName, Owner owner, String description, |