?? shoppingcartitem.java
字號:
package com.cavaness.beer4all.framework;import com.cavaness.beer4all.catalog.view.ItemView;//購物車中的商品類public class ShoppingCartItem { //設置商品,計算此類商品總價格 public void setItem(ItemView newItem) { item = newItem; calculateExtendedPrice(); } //設置此類商品總價格 public void setExtendedPrice(double newPrice) { extendedPrice = newPrice; } //獲取商品的描述信息 public String getDescription() { return item.getDescription(); } //獲取商品編號 public Integer getId() { return item.getOid(); } //獲取商品名 public String getName() { return item.getName(); } //帶商品及商品數量初始化購物車中的商品類 public ShoppingCartItem(ItemView item, int qty) { this.item = item; this.quantity = qty; calculateExtendedPrice(); } //獲取商品數量 public int getQuantity() { return quantity; } //設置商品數量 public void setQuantity(int newQuantity) { quantity = newQuantity; calculateExtendedPrice(); } //獲取商品信息 public ItemView getItem() { return item; } //獲取商品單價 public Double getUnitPrice() { return item.getPrice(); } //獲取此類商品總價格 public double getExtendedPrice() { return extendedPrice; } //計算此類商品總價格 private void calculateExtendedPrice() { if ( item.getPrice() != null ){ extendedPrice = item.getPrice().doubleValue() * getQuantity(); } } private double extendedPrice = 0.0; //此類商品總價格 private ItemView item = null; //商品 private int quantity = 1; //數量}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -