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 , int nRooms,int nKitchens,int nBaths,
24 int nLivings,int nParkings) {
25 this.houseNumber = houseNumber;
26 this.description = description;
29 this.features = new HouseFeatures(nRooms,nKitchens,nBaths,nLivings,nParkings);
30 offers=new Vector<Offer>();
33 public RuralHouse(int houseNumber, Owner owner, String town , int nRooms,int nKitchens,int nBaths,
34 int nLivings,int nParkings) {
35 this.houseNumber = houseNumber;
36 this.description = null;
39 this.features = new HouseFeatures(nRooms,nKitchens,nBaths,nLivings,nParkings);
40 offers=new Vector<Offer>();
43 public int getHouseNumber() {
47 public void setHouseNumber(int houseNumber) {
48 this.houseNumber = houseNumber;
51 public String getDescription() {
55 public void setDescription(String description) {
56 this.description=description;
59 public Owner getOwner() {
63 public void setOwner(Owner owner) {
67 public String getTown() {
71 public void setTown(String town) {
75 public String toString() {
76 return this.houseNumber + ": " + this.town;
79 public Offer createOffer(Date firstDay, Date lastDay, float price) {
80 Offer off=new Offer(this, firstDay, lastDay, price);
86 public int hashCode() {
89 result = prime * result + houseNumber;
94 public boolean equals(Object obj) {
99 if (getClass() != obj.getClass())
101 RuralHouse other = (RuralHouse) obj;
102 if (houseNumber != other.houseNumber)
107 public String getAccountNumber(int houseNumber) {
109 dbMngr=DBManager.getInstance();
110 return dbMngr.getOwner(houseNumber).getBankAccount();
112 } catch (Exception e) {
113 System.out.println("Error, accessing to DB Manager: "
120 * This method obtains available offers for a concrete house in a certain period
122 * @param houseNumber, the house number where the offers must be obtained
123 * @param firstDay, first day in a period range
124 * @param lastDay, last day in a period range
125 * @return a vector of offers(Offer class) available in this period
127 public Vector<Offer> getOffers( Date firstDay, Date lastDay) {
128 Vector<Offer> availableOffers=new Vector<Offer>();
129 Iterator<Offer> e=offers.iterator();
133 if ( (offer.getFirstDay().compareTo(firstDay)>=0) && (offer.getLastDay().compareTo(lastDay)<=0) && (offer.getBooking()==null) )
134 availableOffers.add(offer);
136 return availableOffers;
140 * This method obtains the offer that match exactly with a given dates that has not been booked
142 * @param firstDay, first day in a period range
143 * @param lastDay, last day in a period range
144 * @return the offer(Offer class) available for a this period
146 public Offer findOffer( Date firstDay, Date lastDay) {
147 Iterator<Offer> e=offers.iterator();
151 if ( (offer.getFirstDay().compareTo(firstDay)==0) && (offer.getLastDay().compareTo(lastDay)==0) && (offer.getBooking()==null) )