1 package org.springframework.samples.jpetstore.domain; 2 3 import java.io.Serializable ; 4 5 public class CartItem implements Serializable { 6 7 8 9 private Item item; 10 private int quantity; 11 private boolean inStock; 12 13 14 15 public boolean isInStock() { return inStock; } 16 public void setInStock(boolean inStock) { this.inStock = inStock; } 17 18 public Item getItem() { return item; } 19 public void setItem(Item item) { 20 this.item = item; 21 } 22 23 public int getQuantity() { return quantity; } 24 public void setQuantity(int quantity) { 25 this.quantity = quantity; 26 } 27 28 public double getTotalPrice() { 29 if (item != null) { 30 return item.getListPrice() * quantity; 31 } 32 else { 33 return 0; 34 } 35 } 36 37 38 39 public void incrementQuantity() { 40 quantity++; 41 } 42 43 } 44 | Popular Tags |