1 | import java.util.Objects;
|
---|
2 |
|
---|
3 | public class Option {
|
---|
4 | private int id;
|
---|
5 | private String hotelName;
|
---|
6 | private String country;
|
---|
7 | private float price;
|
---|
8 | private String link;
|
---|
9 | private String imgSrc;
|
---|
10 |
|
---|
11 | //Price changing
|
---|
12 | private float newPrice = 0;
|
---|
13 | private boolean isPriceChanged = false;
|
---|
14 | private String dateRange;
|
---|
15 | // Constructor
|
---|
16 | public Option(){
|
---|
17 | price = 0;
|
---|
18 | }
|
---|
19 |
|
---|
20 | public void setDateRange(String dateRange) {
|
---|
21 | this.dateRange = dateRange;
|
---|
22 | }
|
---|
23 |
|
---|
24 | public String getDateRange() {
|
---|
25 | return dateRange;
|
---|
26 | }
|
---|
27 |
|
---|
28 | public boolean isEmpty(){
|
---|
29 | return (hotelName == null || country == null || price == 0 || link == null || imgSrc == null);
|
---|
30 | }
|
---|
31 | public String getHotelName() {
|
---|
32 | return hotelName;
|
---|
33 | }
|
---|
34 |
|
---|
35 | public void setHotelName(String hotelName) {
|
---|
36 | this.hotelName = hotelName;
|
---|
37 | }
|
---|
38 |
|
---|
39 | public String getCountry() {
|
---|
40 | return country;
|
---|
41 | }
|
---|
42 |
|
---|
43 | public void setCountry(String country) {
|
---|
44 | this.country = country;
|
---|
45 | }
|
---|
46 |
|
---|
47 | public float getPrice() {
|
---|
48 | return price;
|
---|
49 | }
|
---|
50 |
|
---|
51 | public void setPrice(float price) {
|
---|
52 | this.price = price;
|
---|
53 | }
|
---|
54 |
|
---|
55 | public String getLink() {
|
---|
56 | return link;
|
---|
57 | }
|
---|
58 |
|
---|
59 | public void setLink(String link) {
|
---|
60 | this.link = link;
|
---|
61 | }
|
---|
62 |
|
---|
63 | public void setImgSrc(String imgSrc) {
|
---|
64 | this.imgSrc = imgSrc;
|
---|
65 | }
|
---|
66 |
|
---|
67 | public String getImgSrc() {
|
---|
68 | return imgSrc;
|
---|
69 | }
|
---|
70 |
|
---|
71 | @Override
|
---|
72 | public boolean equals(Object obj) {
|
---|
73 | if(this==obj) return true;
|
---|
74 | if(obj == null || getClass() != obj.getClass()) return false;
|
---|
75 | Option option = (Option) obj;
|
---|
76 | return Float.compare(option.price, price) == 0
|
---|
77 | && Objects.equals(hotelName, option.hotelName)
|
---|
78 | && Objects.equals(country, option.country)
|
---|
79 | && Objects.equals(link, option.link);
|
---|
80 | }
|
---|
81 |
|
---|
82 | @Override
|
---|
83 | public int hashCode() {
|
---|
84 | return Objects.hash(hotelName,country,price,link);
|
---|
85 | }
|
---|
86 |
|
---|
87 | public int getId() {
|
---|
88 | return id;
|
---|
89 | }
|
---|
90 |
|
---|
91 | public void setId(int id) {
|
---|
92 | this.id = id;
|
---|
93 | }
|
---|
94 |
|
---|
95 | //debug
|
---|
96 | @Override
|
---|
97 | public String toString() {
|
---|
98 | return "Option{" +
|
---|
99 | "id='" + id + '\'' +
|
---|
100 | "dateRange='" + dateRange + '\'' +
|
---|
101 | "hotelName='" + hotelName + '\'' +
|
---|
102 | ", country='" + country + '\'' +
|
---|
103 | ", price='" + price + '\'' +
|
---|
104 | ", link='" + link + '\'' +
|
---|
105 | ", image='" + imgSrc +
|
---|
106 | '}';
|
---|
107 | }
|
---|
108 |
|
---|
109 | public void setPriceChanged(boolean a){
|
---|
110 | isPriceChanged = a;
|
---|
111 | }
|
---|
112 | public void setNewPrice(float a){
|
---|
113 | newPrice = a;
|
---|
114 | }
|
---|
115 |
|
---|
116 | public boolean isPriceChanged() {
|
---|
117 | return isPriceChanged;
|
---|
118 | }
|
---|
119 |
|
---|
120 | public float getNewPrice() {
|
---|
121 | return newPrice;
|
---|
122 | }
|
---|
123 | }
|
---|