1 7 package org.jfox.petstore.domain; 8 9 import java.io.Serializable ; 10 11 import org.jfox.petstore.entity.Item; 12 13 16 public class CartItem implements Serializable { 17 18 19 20 private Item item; 21 private int quantity; 22 private boolean inStock; 23 24 public boolean isInStock() { 25 return inStock; 26 } 27 28 public void setInStock(boolean inStock) { 29 this.inStock = inStock; 30 } 31 32 public Item getItem() { 33 return item; 34 } 35 36 public void setItem(Item item) { 37 this.item = item; 38 } 39 40 public int getQuantity() { 41 return quantity; 42 } 43 44 public void setQuantity(int quantity) { 45 this.quantity = quantity; 46 } 47 48 public double getTotalPrice() { 49 if (item != null) { 50 return item.getListPrice() * quantity; 51 } 52 else { 53 return 0; 54 } 55 } 56 57 public void incrementQuantity() { 58 quantity++; 59 } 60 61 } 62 | Popular Tags |