House features gui created
[RRRRHHHH_Code] / ruralHouses / src / domain / RuralHouse.java
index 7087a66..423d5e7 100644 (file)
@@ -9,34 +9,35 @@ public class RuralHouse implements Serializable {
 
        private static final long serialVersionUID = 1L;
 
-       private int houseNumber;
+       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(int houseNumber, Owner owner, String description, String town ,HouseFeatures features) {
-               this.houseNumber = houseNumber;
+       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>();
        }
        
        
 
-       public int getHouseNumber() {
-               return houseNumber;
+       public String getHouseName() {
+               return houseName;
        }
 
-       public void setHouseNumber(int houseNumber) {
-               this.houseNumber = houseNumber;
+       public void setHouseName(String houseName) {
+               this.houseName = houseName;
        }
 
        public String getDescription() {
@@ -55,12 +56,12 @@ public class RuralHouse implements Serializable {
                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;
@@ -70,22 +71,18 @@ public class RuralHouse implements Serializable {
                this.features = features;
        }       
        public String toString() {
-               return this.houseNumber + ": " + this.town;
+               return this.houseName + ": " + this.district;
        }
        
-       public Offer createOffer(Date firstDay, Date lastDay, float price) {
-        Offer off=new Offer(this, firstDay, lastDay, price);
+       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 int hashCode() {
-               final int prime = 31;
-               int result = 1;
-               result = prime * result + houseNumber;
-               return result;
-       }
+
+
+
 
        @Override
        public boolean equals(Object obj) {
@@ -96,15 +93,15 @@ public class RuralHouse implements Serializable {
                if (getClass() != obj.getClass())
                        return false;
                RuralHouse other = (RuralHouse) obj;
-               if (houseNumber != other.houseNumber)
+               if (houseName != other.houseName)
                        return false;
                return true;
        }
        
-       public String getAccountNumber(int houseNumber) {
+       public String getAccountNumber(int houseName) {
                /*try {
                        dbMngr=DBManager.getInstance();
-                       return dbMngr.getOwner(houseNumber).getBankAccount();
+                       return dbMngr.getOwner(houseName).getBankAccount();
 
                } catch (Exception e) {
                        System.out.println("Error, accessing to DB Manager: "
@@ -116,7 +113,7 @@ public class RuralHouse implements Serializable {
        /**
         * This method obtains available offers for a concrete house in a certain period 
         * 
-        * @param houseNumber, the house number where the offers must be obtained 
+        * @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
@@ -133,7 +130,17 @@ public class RuralHouse implements Serializable {
                return availableOffers;
        }
        
-       
+       public Vector<Offer> getAllOffers() {
+               Vector<Offer> availableOffers=new Vector<Offer>();
+               Iterator<Offer> e=offers.iterator();
+               Offer offer;
+               while (e.hasNext()){
+                       offer=e.next();
+                       if ( (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
         * 
@@ -153,5 +160,17 @@ public class RuralHouse implements Serializable {
        }
        
        
+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;
+               
+       }
 
 }