RRRRHHHH_Code
Diff Revisions
e3043c ...
vs
b09f34 ...
for ruralHouses/src/domain/RuralHouse.java
|
@@ -14,8 +14,7 @@ |
14 |
14 |
|
private Owner owner; |
15 |
15 |
|
private String district; |
16 |
16 |
|
private HouseFeatures features; |
17 |
|
- |
private Vector<Offer> offers; |
18 |
|
- |
private boolean isAccepted; |
|
17 |
+ |
public Vector<Offer> offers; |
19 |
18 |
|
|
20 |
19 |
|
|
21 |
20 |
|
public RuralHouse() { |
|
@@ -100,59 +99,7 @@ |
100 |
99 |
|
return true; |
101 |
100 |
|
} |
102 |
101 |
|
|
103 |
|
- |
/** |
104 |
|
- |
* This method obtains available offers for a concrete house in a certain |
105 |
|
- |
* period |
106 |
|
- |
* |
107 |
|
- |
* @param houseName |
108 |
|
- |
* , the house number where the offers must be obtained |
109 |
|
- |
* @param firstDay |
110 |
|
- |
* , first day in a period range |
111 |
|
- |
* @param lastDay |
112 |
|
- |
* , last day in a period range |
113 |
|
- |
* @return a vector of offers(Offer class) available in this period |
114 |
|
- |
*/ |
115 |
|
- |
public Vector<Offer> getOffers(Date firstDay, Date lastDay) { |
116 |
|
- |
Vector<Offer> availableOffers = new Vector<Offer>(); |
117 |
|
- |
Iterator<Offer> e = offers.iterator(); |
118 |
|
- |
Offer offer; |
119 |
|
- |
while (e.hasNext()) { |
120 |
|
- |
offer = e.next(); |
121 |
|
- |
if ((offer.getFirstDay().compareTo(firstDay) >= 0) |
122 |
|
- |
&& (offer.getLastDay().compareTo(lastDay) <= 0) |
123 |
|
- |
&& (!offer.isBooked())) |
124 |
|
- |
availableOffers.add(offer); |
125 |
|
- |
} |
126 |
|
- |
return availableOffers; |
127 |
|
- |
} |
128 |
102 |
|
|
129 |
|
- |
public Vector<Offer> getAllOffers() { |
130 |
|
- |
|
131 |
|
- |
return this.offers; |
132 |
|
- |
} |
133 |
|
- |
|
134 |
|
- |
/** |
135 |
|
- |
* This method obtains the offer that match exactly with a given dates that |
136 |
|
- |
* has not been booked |
137 |
|
- |
* |
138 |
|
- |
* @param firstDay |
139 |
|
- |
* , first day in a period range |
140 |
|
- |
* @param lastDay |
141 |
|
- |
* , last day in a period range |
142 |
|
- |
* @return the offer(Offer class) available for a this period |
143 |
|
- |
*/ |
144 |
|
- |
public Offer findOffer(Date firstDay, Date lastDay) { |
145 |
|
- |
Iterator<Offer> e = offers.iterator(); |
146 |
|
- |
Offer offer = null; |
147 |
|
- |
while (e.hasNext()) { |
148 |
|
- |
offer = e.next(); |
149 |
|
- |
if ((offer.getFirstDay().compareTo(firstDay) == 0) |
150 |
|
- |
&& (offer.getLastDay().compareTo(lastDay) == 0) |
151 |
|
- |
&& (!offer.isBooked())) |
152 |
|
- |
return offer; |
153 |
|
- |
} |
154 |
|
- |
return null; |
155 |
|
- |
} |
156 |
103 |
|
|
157 |
104 |
|
public Offer overlapsWith(Date firstDay, Date lastDay) { |
158 |
105 |
|
|
|
@@ -167,13 +114,12 @@ |
167 |
114 |
|
return null; |
168 |
115 |
|
|
169 |
116 |
|
} |
|
117 |
+ |
|
170 |
118 |
|
|
171 |
|
- |
public boolean isAccepted() { |
172 |
|
- |
return isAccepted; |
173 |
|
- |
} |
|
119 |
+ |
public Vector<Offer> getAllOffers() { |
174 |
120 |
|
|
175 |
|
- |
public void setAccepted(boolean isAccepted) { |
176 |
|
- |
this.isAccepted = isAccepted; |
|
121 |
+ |
return this.offers; |
177 |
122 |
|
} |
178 |
123 |
|
|
|
124 |
+ |
|
179 |
125 |
|
} |