package myBean; import java.math.BigDecimal; public class CartGoodsInf { private String goodsId;//商品ID private String goodsName;//商品名称 private double price;//商品单价 private int goodsAmount;//商品数量 private double totalPrice;//商品总价 //构造方法 public CartGoodsInf(String goodsId,String goodsName,double price,int goodsAmount){ this.goodsId=goodsId; this.goodsName=goodsName; this.price=price; this.goodsAmount=goodsAmount; } public int getGoodsAmount(){ return goodsAmount; } public void setGoodsAmount(int goodsAmount){ this.goodsAmount=goodsAmount; } public String getGoodsId(){ return goodsId; } public void setGoodsId(String goodsId){ this.goodsId=goodsId; } public String getGoodsName(){ return goodsName; } public void setGoodsName(String goodsName){ this.goodsName=goodsName; } public double getGoodsPrice(){ return price; } public void setGoodsPrice(double goodsPrice){ this.price=goodsPrice; } public double getTotalPrice(){ this.totalPrice=this.price*(double)this.goodsAmount; BigDecimal total=new BigDecimal(this.totalPrice); total=total.setScale(2,5); this.totalPrice=total.doubleValue(); return this.totalPrice; } public void setTotalPrice(double totalPrice){ this.totalPrice=totalPrice; } }