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