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)
101 public String getAccountNumber(int houseName) {
103 dbMngr=DBManager.getInstance();
104 return dbMngr.getOwner(houseName).getBankAccount();
106 } catch (Exception e) {
107 System.out.println("Error, accessing to DB Manager: "
114 * This method obtains available offers for a concrete house in a certain period
116 * @param houseName, the house number where the offers must be obtained
117 * @param firstDay, first day in a period range
118 * @param lastDay, last day in a period range
119 * @return a vector of offers(Offer class) available in this period
121 public Vector<Offer> getOffers( Date firstDay, Date lastDay) {
122 Vector<Offer> availableOffers=new Vector<Offer>();
123 Iterator<Offer> e=offers.iterator();
127 if ( (offer.getFirstDay().compareTo(firstDay)>=0) && (offer.getLastDay().compareTo(lastDay)<=0) && (offer.getBooking()==null) )
128 availableOffers.add(offer);
130 return availableOffers;
135 * This method obtains the offer that match exactly with a given dates that has not been booked
137 * @param firstDay, first day in a period range
138 * @param lastDay, last day in a period range
139 * @return the offer(Offer class) available for a this period
141 public Offer findOffer( Date firstDay, Date lastDay) {
142 Iterator<Offer> e=offers.iterator();
146 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) && (offer.getLastDay().compareTo(firstDay)>0))