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 private Vector<Offer> offers;
18 private boolean isAccepted;
25 public RuralHouse(String houseName, Owner owner, String description,
26 String ds, HouseFeatures features) {
27 this.houseName = houseName;
28 this.description = description;
31 this.features = features;
32 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) {
67 public HouseFeatures getFeatures() {
71 public void setFeatures(HouseFeatures features) {
72 this.features = features;
75 public String toString() {
76 return this.houseName + ": " + this.district;
79 public Offer createOffer(int offerNumber, Date firstDay, Date lastDay,
81 Offer off = new Offer(offerNumber, this, firstDay, lastDay, price);
87 public boolean equals(Object obj) {
92 if (getClass() != obj.getClass())
94 RuralHouse other = (RuralHouse) obj;
95 if (houseName == null) {
96 if (other.houseName != null)
98 } else if (!houseName.equals(other.houseName))
104 * This method obtains available offers for a concrete house in a certain
108 * , the house number where the offers must be obtained
110 * , first day in a period range
112 * , last day in a period range
113 * @return a vector of offers(Offer class) available in this period
115 public Vector<Offer> getOffers(Date firstDay, Date lastDay) {
116 Vector<Offer> availableOffers = new Vector<Offer>();
117 Iterator<Offer> e = offers.iterator();
119 while (e.hasNext()) {
121 if ((offer.getFirstDay().compareTo(firstDay) >= 0)
122 && (offer.getLastDay().compareTo(lastDay) <= 0)
123 && (!offer.isBooked()))
124 availableOffers.add(offer);
126 return availableOffers;
129 public Vector<Offer> getAllOffers() {
135 * This method obtains the offer that match exactly with a given dates that
136 * has not been booked
139 * , first day in a period range
141 * , last day in a period range
142 * @return the offer(Offer class) available for a this period
144 public Offer findOffer(Date firstDay, Date lastDay) {
145 Iterator<Offer> e = offers.iterator();
147 while (e.hasNext()) {
149 if ((offer.getFirstDay().compareTo(firstDay) == 0)
150 && (offer.getLastDay().compareTo(lastDay) == 0)
151 && (!offer.isBooked()))
157 public Offer overlapsWith(Date firstDay, Date lastDay) {
159 Iterator<Offer> e = offers.iterator();
161 while (e.hasNext()) {
163 if ((offer.getFirstDay().compareTo(lastDay) < 0)
164 && (offer.getLastDay().compareTo(firstDay) > 0))
171 public boolean isAccepted() {
175 public void setAccepted(boolean isAccepted) {
176 this.isAccepted = isAccepted;