3 import java.io.Serializable;
5 import java.util.Iterator;
6 import java.util.Vector;
8 public class RuralHouse implements Serializable {
10 private static final long serialVersionUID = 1L;
12 private String houseName;
13 private String description;
15 private String district;
16 private HouseFeatures features;
17 public Vector<Offer> offers;
18 public boolean isAccepted;
24 public RuralHouse(String houseName, Owner owner, String description, String ds , HouseFeatures features) {
25 this.houseName = houseName;
26 this.description = description;
29 this.features = features;
30 offers=new Vector<Offer>();
35 public String getHouseName() {
39 public void setHouseName(String houseName) {
40 this.houseName = houseName;
43 public String getDescription() {
47 public void setDescription(String description) {
48 this.description=description;
51 public Owner getOwner() {
55 public void setOwner(Owner owner) {
59 public String getDistrict() {
63 public void setDistrict(String ds) {
66 public HouseFeatures getFeatures() {
70 public void setFeatures(HouseFeatures features) {
71 this.features = features;
73 public String toString() {
74 return this.houseName + ": " + this.district;
77 public Offer createOffer(int offerNumber,Date firstDay, Date lastDay, float price) {
78 Offer off=new Offer(offerNumber,this,firstDay,lastDay,price);
88 public boolean equals(Object obj) {
93 if (getClass() != obj.getClass())
95 RuralHouse other = (RuralHouse) obj;
96 if (houseName != other.houseName)
103 * This method obtains available offers for a concrete house in a certain period
105 * @param houseName, the house number where the offers must be obtained
106 * @param firstDay, first day in a period range
107 * @param lastDay, last day in a period range
108 * @return a vector of offers(Offer class) available in this period
110 public Vector<Offer> getOffers( Date firstDay, Date lastDay) {
111 Vector<Offer> availableOffers=new Vector<Offer>();
112 Iterator<Offer> e=offers.iterator();
116 if ( (offer.getFirstDay().compareTo(firstDay)>=0) && (offer.getLastDay().compareTo(lastDay)<=0) && (offer.getBooking()==null) )
117 availableOffers.add(offer);
119 return availableOffers;
122 public Vector<Offer> getAllOffers() {
123 Vector<Offer> availableOffers=new Vector<Offer>();
124 Iterator<Offer> e=offers.iterator();
128 if ( (offer.getBooking()==null) )
129 availableOffers.add(offer);
131 return availableOffers;
134 * This method obtains the offer that match exactly with a given dates that has not been booked
136 * @param firstDay, first day in a period range
137 * @param lastDay, last day in a period range
138 * @return the offer(Offer class) available for a this period
140 public Offer findOffer( Date firstDay, Date lastDay) {
141 Iterator<Offer> e=offers.iterator();
145 if ( (offer.getFirstDay().compareTo(firstDay)==0) && (offer.getLastDay().compareTo(lastDay)==0) && (offer.getBooking()==null) )
152 public Offer overlapsWith( Date firstDay, Date lastDay) {
154 Iterator<Offer> e=offers.iterator();
158 if ( (offer.getFirstDay().compareTo(lastDay)<0)
159 && (offer.getLastDay().compareTo(firstDay)>0))