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,
25 String ds, HouseFeatures features) {
26 this.houseName = houseName;
27 this.description = description;
30 this.features = features;
31 offers = new Vector<Offer>();
34 public String getHouseName() {
38 public void setHouseName(String houseName) {
39 this.houseName = houseName;
42 public String getDescription() {
46 public void setDescription(String description) {
47 this.description = description;
50 public Owner getOwner() {
54 public void setOwner(Owner owner) {
58 public String getDistrict() {
62 public void setDistrict(String ds) {
66 public HouseFeatures getFeatures() {
70 public void setFeatures(HouseFeatures features) {
71 this.features = features;
74 public String toString() {
75 return this.houseName + ": " + this.district;
78 public Offer createOffer(int offerNumber, Date firstDay, Date lastDay,
80 Offer off = new Offer(offerNumber, this, firstDay, lastDay, price);
86 public boolean equals(Object obj) {
91 if (getClass() != obj.getClass())
93 RuralHouse other = (RuralHouse) obj;
94 if (houseName == null) {
95 if (other.houseName != null)
97 } else if (!houseName.equals(other.houseName))
103 * This method obtains available offers for a concrete house in a certain
107 * , the house number where the offers must be obtained
109 * , first day in a period range
111 * , last day in a period range
112 * @return a vector of offers(Offer class) available in this period
114 public Vector<Offer> getOffers(Date firstDay, Date lastDay) {
115 Vector<Offer> availableOffers = new Vector<Offer>();
116 Iterator<Offer> e = offers.iterator();
118 while (e.hasNext()) {
120 if ((offer.getFirstDay().compareTo(firstDay) >= 0)
121 && (offer.getLastDay().compareTo(lastDay) <= 0)
122 && (offer.getBooking() == null))
123 availableOffers.add(offer);
125 return availableOffers;
128 public Vector<Offer> getAllOffers() {
134 * This method obtains the offer that match exactly with a given dates that
135 * has not been booked
138 * , first day in a period range
140 * , last day in a period range
141 * @return the offer(Offer class) available for a this period
143 public Offer findOffer(Date firstDay, Date lastDay) {
144 Iterator<Offer> e = offers.iterator();
146 while (e.hasNext()) {
148 if ((offer.getFirstDay().compareTo(firstDay) == 0)
149 && (offer.getLastDay().compareTo(lastDay) == 0)
150 && (offer.getBooking() == null))
156 public Offer overlapsWith(Date firstDay, Date lastDay) {
158 Iterator<Offer> e = offers.iterator();
160 while (e.hasNext()) {
162 if ((offer.getFirstDay().compareTo(lastDay) < 0)
163 && (offer.getLastDay().compareTo(firstDay) > 0))