private String district;
private HouseFeatures features;
public Vector<Offer> offers;
- public boolean isAccepted;
public RuralHouse() {
super();
if (getClass() != obj.getClass())
return false;
RuralHouse other = (RuralHouse) obj;
- if (houseName != other.houseName)
+ if (houseName == null) {
+ if (other.houseName != null)
+ return false;
+ } else if (!houseName.equals(other.houseName))
return false;
return true;
}
- /**
- * This method obtains available offers for a concrete house in a certain
- * period
- *
- * @param houseName
- * , the house number where the offers must be obtained
- * @param firstDay
- * , first day in a period range
- * @param lastDay
- * , last day in a period range
- * @return a vector of offers(Offer class) available in this period
- */
- public Vector<Offer> getOffers(Date firstDay, Date lastDay) {
- Vector<Offer> availableOffers = new Vector<Offer>();
- Iterator<Offer> e = offers.iterator();
- Offer offer;
- while (e.hasNext()) {
- offer = e.next();
- if ((offer.getFirstDay().compareTo(firstDay) >= 0)
- && (offer.getLastDay().compareTo(lastDay) <= 0)
- && (offer.getBooking() == null))
- availableOffers.add(offer);
- }
- return availableOffers;
- }
- public Vector<Offer> getAllOffers() {
- Vector<Offer> availableOffers = new Vector<Offer>();
- Iterator<Offer> e = offers.iterator();
- Offer offer;
- while (e.hasNext()) {
- offer = e.next();
- if ((offer.getBooking() == null))
- availableOffers.add(offer);
- }
- return availableOffers;
- }
-
- /**
- * This method obtains the offer that match exactly with a given dates that
- * has not been booked
- *
- * @param firstDay
- * , first day in a period range
- * @param lastDay
- * , last day in a period range
- * @return the offer(Offer class) available for a this period
- */
- public Offer findOffer(Date firstDay, Date lastDay) {
- Iterator<Offer> e = offers.iterator();
- Offer offer = null;
- while (e.hasNext()) {
- offer = e.next();
- if ((offer.getFirstDay().compareTo(firstDay) == 0)
- && (offer.getLastDay().compareTo(lastDay) == 0)
- && (offer.getBooking() == null))
- return offer;
- }
- return null;
- }
public Offer overlapsWith(Date firstDay, Date lastDay) {
return null;
}
+
+
+ public Vector<Offer> getAllOffers() {
- public boolean equals(RuralHouse oRh) {
- return this.getHouseName().equals(oRh.getHouseName());
+ return this.offers;
}
}