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 int houseNumber;
13 private String description;
16 private HouseFeatures features;
17 public Vector<Offer> offers;
23 public RuralHouse(int houseNumber, Owner owner, String description, String town ,HouseFeatures features) {
24 this.houseNumber = houseNumber;
25 this.description = description;
28 this.features = features;
29 offers=new Vector<Offer>();
34 public int getHouseNumber() {
38 public void setHouseNumber(int houseNumber) {
39 this.houseNumber = houseNumber;
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 getTown() {
62 public void setTown(String town) {
65 public HouseFeatures getFeatures() {
69 public void setFeatures(HouseFeatures features) {
70 this.features = features;
72 public String toString() {
73 return this.houseNumber + ": " + this.town;
76 public Offer createOffer(Date firstDay, Date lastDay, float price) {
77 Offer off=new Offer(this, firstDay, lastDay, price);
83 public int hashCode() {
86 result = prime * result + houseNumber;
91 public boolean equals(Object obj) {
96 if (getClass() != obj.getClass())
98 RuralHouse other = (RuralHouse) obj;
99 if (houseNumber != other.houseNumber)
104 public String getAccountNumber(int houseNumber) {
106 dbMngr=DBManager.getInstance();
107 return dbMngr.getOwner(houseNumber).getBankAccount();
109 } catch (Exception e) {
110 System.out.println("Error, accessing to DB Manager: "
117 * This method obtains available offers for a concrete house in a certain period
119 * @param houseNumber, the house number where the offers must be obtained
120 * @param firstDay, first day in a period range
121 * @param lastDay, last day in a period range
122 * @return a vector of offers(Offer class) available in this period
124 public Vector<Offer> getOffers( Date firstDay, Date lastDay) {
125 Vector<Offer> availableOffers=new Vector<Offer>();
126 Iterator<Offer> e=offers.iterator();
130 if ( (offer.getFirstDay().compareTo(firstDay)>=0) && (offer.getLastDay().compareTo(lastDay)<=0) && (offer.getBooking()==null) )
131 availableOffers.add(offer);
133 return availableOffers;
138 * This method obtains the offer that match exactly with a given dates that has not been booked
140 * @param firstDay, first day in a period range
141 * @param lastDay, 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();
149 if ( (offer.getFirstDay().compareTo(firstDay)==0) && (offer.getLastDay().compareTo(lastDay)==0) && (offer.getBooking()==null) )