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

📄 cartitem.java

📁 《电子商店管理系统》——采用JSP、Servlet和JavaBean开发,实现了商品管理、 商品分类、订单处理、会员管理等功能
💻 JAVA
字号:
package com.jspdev.cart;

import java.io.*;
import java.math.*;
import com.jspdev.vo.*;

/**
 *代表了购物车中各个item的信息
 */
public class CartItem implements Serializable {

  /* Private Fields */

  private Item item;
  private int quantity;
  private boolean inStock;
  private BigDecimal total;

  /* JavaBeans Properties */

  public boolean isInStock() { return inStock; }
  public void setInStock(boolean inStock) { this.inStock = inStock; }

  public BigDecimal getTotal() { return total; }

  public Item getItem() { return item; }
  public void setItem(Item item) {
    this.item = item;
    calculateTotal();
  }

  public int getQuantity() { return quantity; }
  public void setQuantity(int quantity) {
    this.quantity = quantity;
    calculateTotal();
  }

  /* Public methods */

  public void incrementQuantity() {
    quantity++;
    calculateTotal();
  }

  /**
   * 计算item的金额
   */

  private void calculateTotal() {
    if (item != null && item.getListPrice() != null) {
      total = item.getListPrice().multiply(new BigDecimal(quantity));
    } else {
      total = null;
    }
  }

}

⌨️ 快捷键说明

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