Started with the separated DB with the given code
[RRRRHHHH_Code] / ruralHousesDB / src / domain / RuralHouse.java
diff --git a/ruralHousesDB/src/domain/RuralHouse.java b/ruralHousesDB/src/domain/RuralHouse.java
new file mode 100644 (file)
index 0000000..0c7fbb7
--- /dev/null
@@ -0,0 +1,125 @@
+package domain;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Vector;
+
+public class RuralHouse implements Serializable {
+
+       private static final long serialVersionUID = 1L;
+
+       private String houseName;
+       private String description;
+       private Owner owner;
+       private String district;
+       private HouseFeatures features;
+       public Vector<Offer> offers;
+
+
+       public RuralHouse() {
+               super();
+       }
+
+       public RuralHouse(String houseName, Owner owner, String description,
+                       String ds, HouseFeatures features) {
+               this.houseName = houseName;
+               this.description = description;
+               this.owner = owner;
+               this.district = ds;
+               this.features = features;
+               offers = new Vector<Offer>();
+       }
+
+       public String getHouseName() {
+               return houseName;
+       }
+
+       public void setHouseName(String houseName) {
+               this.houseName = houseName;
+       }
+
+       public String getDescription() {
+               return description;
+       }
+
+       public void setDescription(String description) {
+               this.description = description;
+       }
+
+       public Owner getOwner() {
+               return owner;
+       }
+
+       public void setOwner(Owner owner) {
+               this.owner = owner;
+       }
+
+       public String getDistrict() {
+               return district;
+       }
+
+       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.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 (this == obj)
+                       return true;
+               if (obj == null)
+                       return false;
+               if (getClass() != obj.getClass())
+                       return false;
+               RuralHouse other = (RuralHouse) obj;
+               if (houseName == null) {
+                       if (other.houseName != null)
+                               return false;
+               } else if (!houseName.equals(other.houseName))
+                       return false;
+               return true;
+       }
+
+
+
+       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;
+       }
+
+
+}