Changeset c164f8f for backend/GlobeGuru-backend/src/main/java/Option.java
- Timestamp:
- 01/09/25 18:31:38 (6 days ago)
- Branches:
- master
- Children:
- 53bad7e
- Parents:
- d4d8f61
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
backend/GlobeGuru-backend/src/main/java/Option.java
rd4d8f61 rc164f8f 1 import java.util.Objects; 2 1 3 public class Option { 4 private int id; 2 5 private String hotelName; 3 6 private String country; 4 private Stringprice;5 private String link; // Ensure to add a field for link7 private float price; 8 private String link; 6 9 private String imgSrc; 10 11 //Price changing 12 private float newPrice = 0; 13 private boolean isPriceChanged = false; 14 private String dateRange; 7 15 // Constructor 8 public Option(){} 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 } 9 27 10 28 public boolean isEmpty(){ 11 return (hotelName == null || country == null || price == null|| link == null || imgSrc == null);29 return (hotelName == null || country == null || price == 0 || link == null || imgSrc == null); 12 30 } 13 // Getters and setters (ensure you have these methods)14 31 public String getHotelName() { 15 32 return hotelName; … … 28 45 } 29 46 30 public StringgetPrice() {47 public float getPrice() { 31 48 return price; 32 49 } 33 50 34 public void setPrice( Stringprice) {51 public void setPrice(float price) { 35 52 this.price = price; 36 53 } … … 52 69 } 53 70 54 // toString method (for debugging purposes) 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 55 96 @Override 56 97 public String toString() { 57 98 return "Option{" + 99 "id='" + id + '\'' + 100 "dateRange='" + dateRange + '\'' + 58 101 "hotelName='" + hotelName + '\'' + 59 102 ", country='" + country + '\'' + 60 103 ", price='" + price + '\'' + 61 104 ", link='" + link + '\'' + 105 ", image='" + imgSrc + 62 106 '}'; 63 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 } 64 123 }
Note:
See TracChangeset
for help on using the changeset viewer.