RRRRHHHH_Code
Diff Revisions
c92b61 ...
vs
d30bcc ...
for ruralHouses/src/domain/RuralHouse.java
|
@@ -98,59 +98,7 @@ |
98 |
98 |
|
return true; |
99 |
99 |
|
} |
100 |
100 |
|
|
101 |
|
- |
/** |
102 |
|
- |
* This method obtains available offers for a concrete house in a certain |
103 |
|
- |
* period |
104 |
|
- |
* |
105 |
|
- |
* @param houseName |
106 |
|
- |
* , the house number where the offers must be obtained |
107 |
|
- |
* @param firstDay |
108 |
|
- |
* , first day in a period range |
109 |
|
- |
* @param lastDay |
110 |
|
- |
* , last day in a period range |
111 |
|
- |
* @return a vector of offers(Offer class) available in this period |
112 |
|
- |
*/ |
113 |
|
- |
public Vector<Offer> getOffers(Date firstDay, Date lastDay) { |
114 |
|
- |
Vector<Offer> availableOffers = new Vector<Offer>(); |
115 |
|
- |
Iterator<Offer> e = offers.iterator(); |
116 |
|
- |
Offer offer; |
117 |
|
- |
while (e.hasNext()) { |
118 |
|
- |
offer = e.next(); |
119 |
|
- |
if ((offer.getFirstDay().compareTo(firstDay) >= 0) |
120 |
|
- |
&& (offer.getLastDay().compareTo(lastDay) <= 0) |
121 |
|
- |
&& (!offer.isBooked())) |
122 |
|
- |
availableOffers.add(offer); |
123 |
|
- |
} |
124 |
|
- |
return availableOffers; |
125 |
|
- |
} |
126 |
|
- |
|
127 |
|
- |
public Vector<Offer> getAllOffers() { |
128 |
101 |
|
|
129 |
|
- |
return this.offers; |
130 |
|
- |
} |
131 |
|
- |
|
132 |
|
- |
/** |
133 |
|
- |
* This method obtains the offer that match exactly with a given dates that |
134 |
|
- |
* has not been booked |
135 |
|
- |
* |
136 |
|
- |
* @param firstDay |
137 |
|
- |
* , first day in a period range |
138 |
|
- |
* @param lastDay |
139 |
|
- |
* , last day in a period range |
140 |
|
- |
* @return the offer(Offer class) available for a this period |
141 |
|
- |
*/ |
142 |
|
- |
public Offer findOffer(Date firstDay, Date lastDay) { |
143 |
|
- |
Iterator<Offer> e = offers.iterator(); |
144 |
|
- |
Offer offer = null; |
145 |
|
- |
while (e.hasNext()) { |
146 |
|
- |
offer = e.next(); |
147 |
|
- |
if ((offer.getFirstDay().compareTo(firstDay) == 0) |
148 |
|
- |
&& (offer.getLastDay().compareTo(lastDay) == 0) |
149 |
|
- |
&& (!offer.isBooked())) |
150 |
|
- |
return offer; |
151 |
|
- |
} |
152 |
|
- |
return null; |
153 |
|
- |
} |
154 |
102 |
|
|
155 |
103 |
|
public Offer overlapsWith(Date firstDay, Date lastDay) { |
156 |
104 |
|
|
|
@@ -165,5 +113,11 @@ |
165 |
113 |
|
return null; |
166 |
114 |
|
|
167 |
115 |
|
} |
|
116 |
+ |
|
|
117 |
+ |
|
|
118 |
+ |
public Vector<Offer> getAllOffers() { |
|
119 |
+ |
|
|
120 |
+ |
return this.offers; |
|
121 |
+ |
} |
168 |
122 |
|
|
169 |
123 |
|
} |