⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shoppingcartitem.java

📁 一个netstore的完整代码,他使用了j2ee和webservice技术,并使用ojb o/r管理框架,很不错的
💻 JAVA
字号:
package netstore.framework;

import netstore.catalog.view.ItemDetailView;

/**
 * This wraps the actual item class to help decouple the shopping cart from
 * the actual items it stores.
 */
public class ShoppingCartItem {
  public void setItem(ItemDetailView newItem) {
    item = newItem;
    calculateExtendedPrice();
  }
  public void setExtendedPrice(double newPrice) {
    extendedPrice = newPrice;
  }
  public String getDescription() {
    return item.getDescription();
  }
  public String getId() {
    return item.getId();
  }
  public String getName() {
    return item.getName();
  }
  public ShoppingCartItem(ItemDetailView item, int qty) {
    this.item = item;
    this.quantity = qty;
    calculateExtendedPrice();
  }
  public int getQuantity() {
    return quantity;
  }
  public void setQuantity(int newQuantity) {
    quantity = newQuantity;
    calculateExtendedPrice();
  }
  public ItemDetailView getItem() {
    return item;
  }
  public Double getUnitPrice() {
    return item.getUnitPrice();
  }
  public double getExtendedPrice() {
    return extendedPrice;
  }
  private void calculateExtendedPrice() {
    if ( item.getUnitPrice() != null ){
      extendedPrice = item.getUnitPrice().doubleValue() * getQuantity();
    }
  }

  // Extended price is unit price * qty
  private double extendedPrice = 0.0;
  private ItemDetailView item = null;

  // Default qty to 1
  private int quantity = 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -