cartitem.java
来自「续购物车」· Java 代码 · 共 39 行
JAVA
39 行
package shopping.objectType;
/**
* 顾客购买的每个商品,设计CartItem对象记录商品的购买情况
* 购买的每个商品、购买的数量和该商品的小计金额
* @author lijin
*/
public class CartItem {
private Product product;
private Integer quantity;
private Double itemPrice;
public void setProduct(Product product){
this.product=product;
}
public void setQuantity(Integer quantity){
this.quantity=quantity;
}
public void setItemPrice(Double itemPrice){
this.itemPrice=itemPrice;
}
public Product getProduct(){
return product;
}
public Integer getQuantity(){
return quantity;
}
/**
* 小计金额
* @return Double
*/
public Double getItemPrice(){
double price=this.getProduct().getProductPrice().doubleValue()*
this.getQuantity().intValue();
return new Double(price);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?