cartitembean.java
来自「java编写的网络购物简洁版」· Java 代码 · 共 60 行
JAVA
60 行
package shop;
import java.io.Serializable;
public class CartItemBean implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 1L;
private productBean pr = null;
//表示选购的图书的数量
private int quantity=0;
public CartItemBean()
{
}
/**
* 构造一个新的项目,数量初始化1
* @param book
*/
public CartItemBean(productBean pr)
{
this.pr=pr;
this.quantity=1;
}
public void seProduct(productBean pr)
{
this.pr = pr;
}
public productBean getproduct()
{
return pr;
}
public void setQuantity(int quantity)
{
this.quantity = quantity;
}
public int getQuantity()
{
return quantity;
}
/**
*得到本条目所购图书价格的合计,总价 = 图书的单价 * 数量。
*/
public float getItemPrice()
{
float price=pr.getPrice()*quantity;
long val=Math.round(price*100);
return val/100.0f;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?