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);
88 public boolean equals(Object obj) {
93 if (getClass() != obj.getClass())
95 RuralHouse other = (RuralHouse) obj;
96 if (houseName == null) {
97 if (other.houseName != null)
99 } else if (!houseName.equals(other.houseName))
105 * This method obtains available offers for a concrete house in a certain
109 * , the house number where the offers must be obtained
111 * , first day in a period range
113 * , last day in a period range
114 * @return a vector of offers(Offer class) available in this period
116 public Vector<Offer> getOffers(Date firstDay, Date lastDay) {
117 Vector<Offer> availableOffers = new Vector<Offer>();
118 Iterator<Offer> e = offers.iterator();
120 while (e.hasNext()) {
122 if ((offer.getFirstDay().compareTo(firstDay) >= 0)
123 && (offer.getLastDay().compareTo(lastDay) <= 0)
124 && (offer.getBooking() == null))
125 availableOffers.add(offer);
127 return availableOffers;
130 public Vector<Offer> getAllOffers() {
131 Vector<Offer> availableOffers = new Vector<Offer>();
132 Iterator<Offer> e = offers.iterator();
134 while (e.hasNext()) {
136 if ((offer.getBooking() == null))
137 availableOffers.add(offer);
139 return availableOffers;
143 * This method obtains the offer that match exactly with a given dates that
144 * has not been booked
147 * , first day in a period range
149 * , last day in a period range
150 * @return the offer(Offer class) available for a this period
152 public Offer findOffer(Date firstDay, Date lastDay) {
153 Iterator<Offer> e = offers.iterator();
155 while (e.hasNext()) {
157 if ((offer.getFirstDay().compareTo(firstDay) == 0)
158 && (offer.getLastDay().compareTo(lastDay) == 0)
159 && (offer.getBooking() == null))
165 public Offer overlapsWith(Date firstDay, Date lastDay) {
167 Iterator<Offer> e = offers.iterator();
169 while (e.hasNext()) {
171 if ((offer.getFirstDay().compareTo(lastDay) < 0)
172 && (offer.getLastDay().compareTo(firstDay) > 0))