c0dfade0c8128fb96a0b7a826490325a11e043fe
[RRRRHHHH_Code] / ruralHouses / src / domain / Offer.java
1 package domain;
2
3 import java.io.*;
4 import java.util.Date;  
5
6
7 @SuppressWarnings("serial")
8 public class Offer implements Serializable {
9         
10
11         private int offerNumber;
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
16         private RuralHouse ruralHouse;
17
18         
19         public Offer(int offerNumber,RuralHouse ruralHouse, Date firstDay, Date lastDay, float price){
20                   this.firstDay=firstDay;
21                   this.lastDay=lastDay;
22                   this.price=price;
23                   this.ruralHouse=ruralHouse;
24                   this.offerNumber=offerNumber;
25         }
26         /**
27          * Get the house number of the offer
28          * 
29          * @return the house number
30          */
31         public RuralHouse getRuralHouse() {
32                 return this.ruralHouse;
33         }
34
35         /**
36          * Set the house number to a offer
37          * 
38          * @param house number
39          */
40         public void setRuralHouse(RuralHouse ruralHouse) {
41                 this.ruralHouse = ruralHouse;
42         }
43
44
45         /**
46          * Get the offer number
47          * 
48          * @return offer number
49          */
50         public int getOfferNumber() {
51                 return this.offerNumber;
52         }
53
54         
55
56         /**
57          * Get the first day of the offer
58          * 
59          * @return the first day
60          */
61         public Date getFirstDay() {
62                 return this.firstDay;
63         }
64
65         /**
66          * Set the first day of the offer
67          * 
68          * @param firstDay
69          *            The first day
70          */
71         public void setFirstDay(Date firstDay) {
72                 this.firstDay = firstDay;
73         }
74
75         /**
76          * Get the last day of the offer
77          * 
78          * @return the last day
79          */
80         public Date getLastDay() {
81                 return this.lastDay;
82         }
83
84         /**
85          * Set the last day of the offer
86          * 
87          * @param lastDay
88          *            The last day
89          */
90         public void setLastDay(Date lastDay) {
91                 this.lastDay = lastDay;
92         }
93
94         /**
95          * Get the price
96          * 
97          * @return price
98          */
99         public float getPrice() {
100                 return this.price;
101         }
102
103         /**
104          * Set the price
105          * 
106          * @param price
107          */
108         public void setPrice(float price) {
109                 this.price = price;
110         }
111
112         /**
113          * Get the book number
114          * 
115          * @return book object
116          */
117         public Booking getBooking() {
118                 return this.booking;
119         }
120
121         /**
122          * Set the book object
123          * 
124          * @param book
125          *            Book object
126          * @return None
127          */
128         public void setBooking(Booking booking) {
129                 this.booking = booking;
130         }
131         
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;
145         }
146 }