private String houseName;
private String description;
private Owner owner;
- private String town;
+ private String district;
private HouseFeatures features;
public Vector<Offer> offers;
- public boolean isAccepted;
-
+
public RuralHouse() {
super();
}
- public RuralHouse(String houseName, Owner owner, String description, String town , HouseFeatures features) {
+ public RuralHouse(String houseName, Owner owner, String description,
+ String ds, HouseFeatures features) {
this.houseName = houseName;
this.description = description;
this.owner = owner;
- this.town = town;
+ this.district = ds;
this.features = features;
- offers=new Vector<Offer>();
+ offers = new Vector<Offer>();
}
-
-
public String getHouseName() {
return houseName;
public String getDescription() {
return description;
}
-
+
public void setDescription(String description) {
- this.description=description;
+ this.description = description;
}
public Owner getOwner() {
}
public void setOwner(Owner owner) {
- this.owner=owner;
+ this.owner = owner;
}
-
- public String getTown() {
- return town;
+
+ public String getDistrict() {
+ return district;
}
-
- public void setTown(String town) {
- this.town=town;
+
+ public void setDistrict(String ds) {
+ this.district = ds;
}
+
public HouseFeatures getFeatures() {
return features;
}
public void setFeatures(HouseFeatures features) {
this.features = features;
- }
- public String toString() {
- return this.houseName + ": " + this.town;
}
-
- public Offer createOffer(int offerNumber,Date firstDay, Date lastDay, float price) {
- Offer off=new Offer(offerNumber,this,firstDay,lastDay,price);
- offers.add(off);
- return off;
- }
-
-
+ public String toString() {
+ return this.houseName + ": " + this.district;
+ }
+ public Offer createOffer(int offerNumber, Date firstDay, Date lastDay,
+ float price) {
+ Offer off = new Offer(offerNumber, this, firstDay, lastDay, price);
+ offers.add(off);
+ return off;
+ }
@Override
public boolean equals(Object obj) {
if (getClass() != obj.getClass())
return false;
RuralHouse other = (RuralHouse) obj;
- if (houseName != other.houseName)
+ if (houseName == null) {
+ if (other.houseName != null)
+ return false;
+ } else if (!houseName.equals(other.houseName))
return false;
return true;
}
-
- public String getAccountNumber(int houseName) {
- /*try {
- dbMngr=DBManager.getInstance();
- return dbMngr.getOwner(houseName).getBankAccount();
- } catch (Exception e) {
- System.out.println("Error, accessing to DB Manager: "
- + e.toString());
- return null;
- }*/ return null;
- }
-
- /**
- * This method obtains available offers for a concrete house in a certain period
- *
- * @param houseName, the house number where the offers must be obtained
- * @param firstDay, first day in a period range
- * @param lastDay, last day in a period range
- * @return a vector of offers(Offer class) available in this period
- */
- public Vector<Offer> getOffers( Date firstDay, Date lastDay) {
- Vector<Offer> availableOffers=new Vector<Offer>();
- Iterator<Offer> e=offers.iterator();
- Offer offer;
- while (e.hasNext()){
- offer=e.next();
- if ( (offer.getFirstDay().compareTo(firstDay)>=0) && (offer.getLastDay().compareTo(lastDay)<=0) && (offer.getBooking()==null) )
- availableOffers.add(offer);
- }
- return availableOffers;
- }
-
-
- /**
- * This method obtains the offer that match exactly with a given dates that has not been booked
- *
- * @param firstDay, first day in a period range
- * @param lastDay, last day in a period range
- * @return the offer(Offer class) available for a this period
- */
- public Offer findOffer( Date firstDay, Date lastDay) {
- Iterator<Offer> e=offers.iterator();
- Offer offer=null;
- while (e.hasNext()){
- offer=e.next();
- if ( (offer.getFirstDay().compareTo(firstDay)==0) && (offer.getLastDay().compareTo(lastDay)==0) && (offer.getBooking()==null) )
+
+
+ public Offer overlapsWith(Date firstDay, Date lastDay) {
+
+ Iterator<Offer> e = offers.iterator();
+ Offer offer = null;
+ while (e.hasNext()) {
+ offer = e.next();
+ if ((offer.getFirstDay().compareTo(lastDay) < 0)
+ && (offer.getLastDay().compareTo(firstDay) > 0))
return offer;
}
- return null;
+ return null;
+
}
-public Offer overlapsWith( Date firstDay, Date lastDay) {
-
- Iterator<Offer> e=offers.iterator();
- Offer offer=null;
- while (e.hasNext()){
- offer=e.next();
- if ( (offer.getFirstDay().compareTo(lastDay)<0) && (offer.getLastDay().compareTo(firstDay)>0))
- return offer;
- }
- return null;
-
+
+ public Vector<Offer> getAllOffers() {
+
+ return this.offers;
}
}