cartitembean.java

来自「Java.Web开发详解.书中例子的源代码,全部都有」· Java 代码 · 共 51 行

JAVA
51
字号
package org.sunxin.lesson.jsp.bookstore;

import java.io.Serializable;

public class CartItemBean implements Serializable
{
    private BookBean book=null;
    
    //表示选购的图书的数量
    private int quantity=0;
    
    public CartItemBean()
    {
    }
    
    public CartItemBean(BookBean book)
    {
        this.book=book;
        this.quantity=1;
    }
    
    public void setBook(BookBean book)
    {
        this.book = book;
    }
    
    public BookBean getBook()
    {
        return book;
    }
    
    public void setQuantity(int quantity)
    {
        this.quantity = quantity;
    }
    
    public int getQuantity()
    {
        return quantity;
    }
    
    /**
    *得到本条目所购图书价格的合计,总价 = 图书的单价 * 数量。
    */
    public float getItemPrice()
    {
        float price=book.getPrice()*quantity;
        long val=Math.round(price*100);
        return val/100.0f;
    }
}

⌨️ 快捷键说明

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