Git Repository Public Repository

RRRRHHHH_Code

URLs

Copy to Clipboard

Diff Revisions 5761bc ... vs 46d6c3 ... for ruralHouses/src/domain/RuralHouse.java

Diff revisions: vs.
  @@ -12,25 +12,24 @@
12 12 private String houseName;
13 13 private String description;
14 14 private Owner owner;
15 - private String district;
15 + private String district;
16 16 private HouseFeatures features;
17 17 public Vector<Offer> offers;
18 18 public boolean isAccepted;
19 -
19 +
20 20 public RuralHouse() {
21 21 super();
22 22 }
23 23
24 - public RuralHouse(String houseName, Owner owner, String description, String ds , HouseFeatures features) {
24 + public RuralHouse(String houseName, Owner owner, String description,
25 + String ds, HouseFeatures features) {
25 26 this.houseName = houseName;
26 27 this.description = description;
27 28 this.owner = owner;
28 29 this.district = ds;
29 30 this.features = features;
30 - offers=new Vector<Offer>();
31 + offers = new Vector<Offer>();
31 32 }
32 -
33 -
34 33
35 34 public String getHouseName() {
36 35 return houseName;
  @@ -43,9 +42,9 @@
43 42 public String getDescription() {
44 43 return description;
45 44 }
46 -
45 +
47 46 public void setDescription(String description) {
48 - this.description=description;
47 + this.description = description;
49 48 }
50 49
51 50 public Owner getOwner() {
  @@ -53,36 +52,35 @@
53 52 }
54 53
55 54 public void setOwner(Owner owner) {
56 - this.owner=owner;
55 + this.owner = owner;
57 56 }
58 -
57 +
59 58 public String getDistrict() {
60 59 return district;
61 60 }
62 -
61 +
63 62 public void setDistrict(String ds) {
64 - this.district=ds;
63 + this.district = ds;
65 64 }
65 +
66 66 public HouseFeatures getFeatures() {
67 67 return features;
68 68 }
69 69
70 70 public void setFeatures(HouseFeatures features) {
71 71 this.features = features;
72 - }
72 + }
73 +
73 74 public String toString() {
74 75 return this.houseName + ": " + this.district;
75 76 }
76 -
77 - public Offer createOffer(int offerNumber,Date firstDay, Date lastDay, float price) {
78 - Offer off=new Offer(offerNumber,this,firstDay,lastDay,price);
79 - offers.add(off);
80 - return off;
81 - }
82 -
83 -
84 -
85 77
78 + public Offer createOffer(int offerNumber, Date firstDay, Date lastDay,
79 + float price) {
80 + Offer off = new Offer(offerNumber, this, firstDay, lastDay, price);
81 + offers.add(off);
82 + return off;
83 + }
86 84
87 85 @Override
88 86 public boolean equals(Object obj) {
  @@ -98,69 +96,83 @@
98 96 return true;
99 97 }
100 98
101 -
102 99 /**
103 - * This method obtains available offers for a concrete house in a certain period
100 + * This method obtains available offers for a concrete house in a certain
101 + * period
104 102 *
105 - * @param houseName, the house number where the offers must be obtained
106 - * @param firstDay, first day in a period range
107 - * @param lastDay, last day in a period range
108 - * @return a vector of offers(Offer class) available in this period
103 + * @param houseName
104 + * , the house number where the offers must be obtained
105 + * @param firstDay
106 + * , first day in a period range
107 + * @param lastDay
108 + * , last day in a period range
109 + * @return a vector of offers(Offer class) available in this period
109 110 */
110 - public Vector<Offer> getOffers( Date firstDay, Date lastDay) {
111 - Vector<Offer> availableOffers=new Vector<Offer>();
112 - Iterator<Offer> e=offers.iterator();
111 + public Vector<Offer> getOffers(Date firstDay, Date lastDay) {
112 + Vector<Offer> availableOffers = new Vector<Offer>();
113 + Iterator<Offer> e = offers.iterator();
113 114 Offer offer;
114 - while (e.hasNext()){
115 - offer=e.next();
116 - if ( (offer.getFirstDay().compareTo(firstDay)>=0) && (offer.getLastDay().compareTo(lastDay)<=0) && (offer.getBooking()==null) )
115 + while (e.hasNext()) {
116 + offer = e.next();
117 + if ((offer.getFirstDay().compareTo(firstDay) >= 0)
118 + && (offer.getLastDay().compareTo(lastDay) <= 0)
119 + && (offer.getBooking() == null))
117 120 availableOffers.add(offer);
118 121 }
119 122 return availableOffers;
120 123 }
121 -
124 +
122 125 public Vector<Offer> getAllOffers() {
123 - Vector<Offer> availableOffers=new Vector<Offer>();
124 - Iterator<Offer> e=offers.iterator();
126 + Vector<Offer> availableOffers = new Vector<Offer>();
127 + Iterator<Offer> e = offers.iterator();
125 128 Offer offer;
126 - while (e.hasNext()){
127 - offer=e.next();
128 - if ( (offer.getBooking()==null) )
129 + while (e.hasNext()) {
130 + offer = e.next();
131 + if ((offer.getBooking() == null))
129 132 availableOffers.add(offer);
130 133 }
131 134 return availableOffers;
132 135 }
136 +
133 137 /**
134 - * This method obtains the offer that match exactly with a given dates that has not been booked
138 + * This method obtains the offer that match exactly with a given dates that
139 + * has not been booked
135 140 *
136 - * @param firstDay, first day in a period range
137 - * @param lastDay, last day in a period range
138 - * @return the offer(Offer class) available for a this period
141 + * @param firstDay
142 + * , first day in a period range
143 + * @param lastDay
144 + * , last day in a period range
145 + * @return the offer(Offer class) available for a this period
139 146 */
140 - public Offer findOffer( Date firstDay, Date lastDay) {
141 - Iterator<Offer> e=offers.iterator();
142 - Offer offer=null;
143 - while (e.hasNext()){
144 - offer=e.next();
145 - if ( (offer.getFirstDay().compareTo(firstDay)==0) && (offer.getLastDay().compareTo(lastDay)==0) && (offer.getBooking()==null) )
147 + public Offer findOffer(Date firstDay, Date lastDay) {
148 + Iterator<Offer> e = offers.iterator();
149 + Offer offer = null;
150 + while (e.hasNext()) {
151 + offer = e.next();
152 + if ((offer.getFirstDay().compareTo(firstDay) == 0)
153 + && (offer.getLastDay().compareTo(lastDay) == 0)
154 + && (offer.getBooking() == null))
146 155 return offer;
147 156 }
148 - return null;
157 + return null;
149 158 }
150 -
151 -
152 - public Offer overlapsWith( Date firstDay, Date lastDay) {
153 -
154 - Iterator<Offer> e=offers.iterator();
155 - Offer offer=null;
156 - while (e.hasNext()){
157 - offer=e.next();
158 - if ( (offer.getFirstDay().compareTo(lastDay)<0)
159 - && (offer.getLastDay().compareTo(firstDay)>0))
159 +
160 + public Offer overlapsWith(Date firstDay, Date lastDay) {
161 +
162 + Iterator<Offer> e = offers.iterator();
163 + Offer offer = null;
164 + while (e.hasNext()) {
165 + offer = e.next();
166 + if ((offer.getFirstDay().compareTo(lastDay) < 0)
167 + && (offer.getLastDay().compareTo(firstDay) > 0))
160 168 return offer;
161 169 }
162 170 return null;
163 -
171 +
172 + }
173 +
174 + public boolean equals(RuralHouse oRh) {
175 + return this.getHouseName().equals(oRh.getHouseName());
164 176 }
165 177
166 178 }