cartitem.java
来自「工厂版本管理系统,STRUTS2框架,用于管理商品的版本,便于有效的控制版本」· Java 代码 · 共 72 行
JAVA
72 行
package com.bluesky.elecall.domain.cart;import java.math.BigDecimal;import com.bluesky.elecall.domain.Product;public class CartItem { //if productId is invalid, then product is null private Product product; private String productId; private long quantity; public CartItem() { } public CartItem(String productId, long quantity) { this.productId = productId; this.quantity = quantity; } public Product getProduct() { return product; } public void setProduct(Product product) { this.product = product; } public long getQuantity() { return quantity; } public void setQuantity(long quantity) { this.quantity = quantity; } public String getProductId() { return productId; } public void setProductId(String productId) { this.productId = productId; } public void increaseQuantity(long quantity) { this.quantity += quantity; } public BigDecimal getAmount() { return product.getUnitPrice(quantity).multiply(new BigDecimal(quantity)); } public boolean isEmpty() { if(productId==null || productId.equals("") || quantity==0) return true; return false; } public BigDecimal getUnitPrice() { return product.getUnitPrice(quantity); } public boolean isValid(){ if(product!=null && product.getName().length()>0) return true; else return false; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?