Git Repository Public Repository

RRRRHHHH_Code

URLs

Copy to Clipboard

Diff Revisions e0d74d ... vs 06a849 ... for ruralHouses/src/domain/Offer.java

Diff revisions: vs.
  @@ -1,77 +1,146 @@
1 1 package domain;
2 2
3 3 import java.io.*;
4 - //import java.util.Vector;
5 - import java.util.Date;
6 - import businessLogic.OfferManager;
7 - import com.db4o.ObjectContainer;
8 - import dataAccess.DB4oManager;
4 + import java.util.Date;
5 +
9 6
10 7 @SuppressWarnings("serial")
11 8 public class Offer implements Serializable {
12 9
10 +
13 11 private int offerNumber;
14 - private Date firstDay;
15 - private Date lastDay;
16 - private float price;
17 - private Booking booking;
12 + private Date firstDay; // Dates are stored as java.util.Date objects instead of java.sql.Date objects
13 + private Date lastDay; // because, they are not well stored in db4o as java.util.Date objects
14 + private float price; // This is coherent because objects of java.sql.Date are objects of java.util.Date
15 + private Booking booking; // That is: java.sql.Date is a subclass (or extends) java.util.Date
18 16 private RuralHouse ruralHouse;
17 +
19 18
20 - public Offer(RuralHouse ruralHouse, Date firstDay, Date lastDay, float price) {
19 + public Offer(int offerNumber,RuralHouse ruralHouse, Date firstDay, Date lastDay, float price){
21 20 this.firstDay=firstDay;
22 21 this.lastDay=lastDay;
23 22 this.price=price;
24 23 this.ruralHouse=ruralHouse;
25 - this.offerNumber=OfferManager.getNumber();
24 + this.offerNumber=offerNumber;
26 25 }
27 -
26 + /**
27 + * Get the house number of the offer
28 + *
29 + * @return the house number
30 + */
28 31 public RuralHouse getRuralHouse() {
29 32 return this.ruralHouse;
30 33 }
31 34
35 + /**
36 + * Set the house number to a offer
37 + *
38 + * @param house number
39 + */
32 40 public void setRuralHouse(RuralHouse ruralHouse) {
33 41 this.ruralHouse = ruralHouse;
34 42 }
35 43
44 +
45 + /**
46 + * Get the offer number
47 + *
48 + * @return offer number
49 + */
36 50 public int getOfferNumber() {
37 51 return this.offerNumber;
38 52 }
39 53
54 +
55 +
56 + /**
57 + * Get the first day of the offer
58 + *
59 + * @return the first day
60 + */
40 61 public Date getFirstDay() {
41 62 return this.firstDay;
42 63 }
43 64
65 + /**
66 + * Set the first day of the offer
67 + *
68 + * @param firstDay
69 + * The first day
70 + */
44 71 public void setFirstDay(Date firstDay) {
45 72 this.firstDay = firstDay;
46 73 }
47 74
75 + /**
76 + * Get the last day of the offer
77 + *
78 + * @return the last day
79 + */
48 80 public Date getLastDay() {
49 81 return this.lastDay;
50 82 }
51 83
84 + /**
85 + * Set the last day of the offer
86 + *
87 + * @param lastDay
88 + * The last day
89 + */
52 90 public void setLastDay(Date lastDay) {
53 91 this.lastDay = lastDay;
54 92 }
55 93
94 + /**
95 + * Get the price
96 + *
97 + * @return price
98 + */
56 99 public float getPrice() {
57 100 return this.price;
58 101 }
59 102
103 + /**
104 + * Set the price
105 + *
106 + * @param price
107 + */
60 108 public void setPrice(float price) {
61 109 this.price = price;
62 110 }
63 111
112 + /**
113 + * Get the book number
114 + *
115 + * @return book object
116 + */
64 117 public Booking getBooking() {
65 118 return this.booking;
66 119 }
67 120
121 + /**
122 + * Set the book object
123 + *
124 + * @param book
125 + * Book object
126 + * @return None
127 + */
68 128 public void setBooking(Booking booking) {
69 129 this.booking = booking;
70 130 }
71 131
72 - public Booking createBook(String bookTelephoneNumber) {
73 - Booking b=new Booking(bookTelephoneNumber, this);
74 - booking=b;
75 - return booking;
132 + /**
133 + * This method creates a book with a corresponding parameters
134 + *
135 + * @param First day, last day, house number and telephone
136 + * @return a book
137 + */
138 + public Booking createBooking(int numBooking,String bookTelephoneNumber) {
139 + return booking=new Booking(numBooking,bookTelephoneNumber,this);
140 +
141 + }
142 +
143 + public String toString(){
144 + return offerNumber+";"+firstDay.toString()+";"+lastDay.toString()+";"+price+";"+ruralHouse;
76 145 }
77 146 }