00a3e70602e65c2b2a2e3081591207ea1e8dd9b5
[RRRRHHHH_Code] / ruralHouses / src / domain / Offer.java
1 package domain;
2
3 import java.io.Serializable;
4 import java.util.Date;
5 import java.util.LinkedList;
6 import java.util.Vector;
7
8
9 @SuppressWarnings("serial")
10 public class Offer implements Serializable {
11         
12
13         private int offerNumber;
14         private Date firstDay; // Dates are stored as java.util.Date objects instead of java.sql.Date objects
15         private Date lastDay;  // because, they are not well stored in db4o as java.util.Date objects
16         private float price;   // This is coherent because objects of java.sql.Date are objects of java.util.Date 
17         private Vector<Booking> bookings;  // 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 Booking createBooking(int numBooking,String bookTelephoneNumber,String name , String mail) {
122                 Client client = new Client(name,mail,bookTelephoneNumber);
123                 Booking b = new Booking(numBooking,this,client);
124                 this.bookings.add(b);
125                 return b;
126                         
127         }
128         
129         public String toString(){
130                 return firstDay.toString()+", "+lastDay.toString()+", "+price;
131         }
132         public Vector<Booking> getBookings() {
133                 return bookings;
134         }
135         public void setBookings(Vector<Booking> bookings) {
136                 this.bookings = bookings;
137         }
138 }