1 33 34 package com.icesoft.icefaces.samples.showcase.components.dragDrop; 35 36 import com.icesoft.faces.context.effects.Effect; 37 import com.icesoft.faces.context.effects.Highlight; 38 39 import javax.faces.event.ActionEvent; 40 41 47 public class CartItem { 48 private String key = null; 50 private String name = "Unknown"; 51 private double price = 0.0; 52 private boolean isPurchased = false; 53 private int quantity = 0; 54 private int purchasedQuantity = 0; 55 56 private String image; 58 private String imageSmall; 59 60 public static final String ICE_SAILER = "Ice Sailer"; 62 public static final String ICE_CASTLE = "Ice Castle"; 63 public static final String ICE_BERG = "Ice Berg"; 64 public static final String ICE_BREAKER = "Ice Breaker"; 65 66 private CartBean cartBean; 68 69 private Effect effect = new Highlight(); 71 72 public CartItem() { 73 } 74 75 83 public CartItem(CartBean cartBean, String name, double price, 84 int quantity) { 85 this.cartBean = cartBean; 86 this.name = name; 87 this.price = price; 88 this.quantity = quantity; 89 90 image = "./images/dragDrop/" + name.toLowerCase().replace(' ', '_'); 92 imageSmall = image + "_small.jpg"; 93 image += ".jpg"; 94 } 95 96 97 public String getKey() { 98 return (key); 99 } 100 101 public String getName() { 102 return (name); 103 } 104 105 public String getImage() { 106 return (image); 107 } 108 109 public String getImageSmall() { 110 return (imageSmall); 111 } 112 113 public double getPrice() { 114 return (price); 115 } 116 117 public boolean isPurchased() { 118 return (isPurchased); 119 } 120 121 public int getQuantity() { 122 return (quantity); 123 } 124 125 public int getPurchasedQuantity() { 126 return (purchasedQuantity); 127 } 128 129 public double getProductTotalDouble() { 130 return purchasedQuantity * price; 131 } 132 133 public String getProductTotal() { 134 return StoreTable.CURRENCY_FORMAT.format(getProductTotalDouble()); 135 } 136 137 public Effect getEffect() { 138 return effect; 139 } 140 141 142 public void setKey(String key) { 143 this.key = key; 144 } 145 146 public void setName(String name) { 147 this.name = name; 148 } 149 150 public void setImage(String image) { 151 this.image = image; 152 } 153 154 public void setPrice(double price) { 155 this.price = price; 156 } 157 158 public void setPurchased(boolean isPurchased) { 159 this.isPurchased = isPurchased; 160 } 161 162 public void setQuantity(int quantity) { 163 this.quantity = quantity; 164 } 165 166 public void setPurchasedQuantity(int purchasedQuantity) { 167 this.purchasedQuantity = purchasedQuantity; 168 } 169 170 public void setEffect(Effect effect) { 171 this.effect = effect; 172 } 173 174 181 public void returnOne(ActionEvent e) { 182 cartBean.removeFromPurchases(this); 183 } 184 185 188 public void decreaseQuantity() { 189 if (quantity >= 1) { 190 quantity--; 191 purchasedQuantity++; 192 } 193 } 194 195 198 public void increaseQuantity() { 199 quantity++; 200 purchasedQuantity--; 201 } 202 203 209 public String getPriceFormatted() { 210 return (StoreTable.CURRENCY_FORMAT.format(price)); 211 } 212 } 213 | Popular Tags |