1 37 38 package com.sun.j2ee.blueprints.consumerwebsite; 39 40 import java.util.*; 41 42 45 public class Cart implements java.io.Serializable { 46 47 private HashMap activities; 48 private String packageId; 49 private String lodgingId; 50 private String destination; 51 private String departureFlight; 52 private String returnFlight; 53 private String origin; 54 private boolean configurationComplete = false; 55 private int headCount; 56 private int adventureDays =0; 57 private int lodgingDays = 0; 58 private int lodgingRoomCount = 0; 59 private Calendar departureDate = Calendar.getInstance(); 60 private Calendar returnDate = Calendar.getInstance(); 61 62 63 public Cart() { 64 } 65 66 public void addActivity(String itemId) { 67 addActivity(itemId,1); 68 } 69 70 public void addActivity(String itemId, int qty) { 71 if (activities == null) { 72 activities = new HashMap(); 73 } 74 if (activities.containsKey(itemId)) { 75 activities.remove(itemId); 76 } 77 activities.put(itemId, new Integer (qty)); 78 } 79 80 public HashMap getActivities() { 81 return activities; 82 } 83 84 public int getActivityCount() { 85 if (activities == null) return 0; 86 return activities.size(); 87 } 88 89 public void setActivityHeadCount(String itemId, 90 int quantity) { 91 if ((activities != null) && activities.containsKey(itemId)) { 92 activities.remove(itemId); 93 if (quantity > 0) activities.put(itemId, new Integer (quantity)); 94 } 95 } 96 97 public void setLodgingId(String lodgingId) { 98 this.lodgingId = lodgingId; 99 } 100 101 public String getLodgingId() { 102 return lodgingId; 103 } 104 105 public int getLodgingRoomCount() { 106 return lodgingRoomCount; 107 } 108 109 public void setLodgingRoomCount(int lodgingRoomCount) { 110 this.lodgingRoomCount = lodgingRoomCount; 111 } 112 113 public void setDepartureFlight(String departureFlight) { 114 this.departureFlight = departureFlight; 115 } 116 117 public String getDepartureFlight() { 118 return departureFlight; 119 } 120 121 public void setReturnFlight(String returnFlight) { 122 this.returnFlight = returnFlight; 123 } 124 125 public String getReturnFlight() { 126 return returnFlight; 127 } 128 129 public void setOrigin(String origin) { 130 this.origin = origin; 131 } 132 133 public String getOrigin() { 134 return origin; 135 } 136 137 public void setPackageId(String packageId) { 138 this.packageId = packageId; 139 } 140 141 public String getPackageId() { 142 return packageId; 143 } 144 145 public void setDestination(String destination) { 146 this.destination = destination; 147 } 148 149 public String getDestination() { 150 return destination; 151 } 152 153 public int getHeadCount() { 154 return headCount; 155 } 156 157 public void setAdventureDays(int adventureDays) { 158 this.adventureDays = adventureDays; 159 this.lodgingDays = adventureDays - 1; 161 } 162 163 public int getAdventureDays() { 164 return adventureDays; 165 } 166 167 public int getLodgingDays() { 168 return lodgingDays; 169 } 170 171 public void setLodgingDays(int lodgingDays) { 172 this.lodgingDays = lodgingDays; 173 } 174 175 public void setHeadCount(int headCount) { 176 this.headCount = headCount; 177 } 178 179 public Collection getActivityIds() { 180 if (activities == null) return null; 181 return activities.keySet(); 182 } 183 184 public Collection getValues() { 185 if (activities == null) return null; 186 return activities.values(); 187 } 188 189 public Calendar getDepartureDate() { 190 return departureDate; 191 } 192 193 public void setDepartureDate(Calendar departureDate) { 194 this.departureDate = departureDate; 195 } 196 197 public Calendar getReturnDate() { 198 return returnDate; 199 } 200 201 public void setReturnDate(Calendar returnDate) { 202 this.returnDate = returnDate; 203 } 204 205 public boolean isConfigurationComplete() { 206 return configurationComplete; 207 } 208 209 public void setConfigurationComplete(boolean configurationComplete) { 210 this.configurationComplete = configurationComplete; 211 } 212 213 public void clear() { 214 packageId = null; 215 activities = null; 216 lodgingId = null; 217 origin = null; 218 headCount = 0; 219 lodgingDays = 0; 220 lodgingRoomCount = 0; 221 adventureDays = 0; 222 returnFlight = null; 223 departureFlight = null; 224 departureDate = null; 225 configurationComplete = false; 226 } 227 } 228 | Popular Tags |