⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shoppingcartitem.java

📁 beginJsp2.0外文书籍源代码
💻 JAVA
字号:
package com.wrox.shop;

/**
 * Models a shopping cart item consisting of a Book and a quantity.
 */
public class ShoppingCartItem 
{
  
  private final Book book;
  private int quantity;

  public ShoppingCartItem(Book book) 
  {
    super();
    this.book = book;
    this.quantity = 1;
  }
  
  public Book getBook() 
  {
    return book;  
  }
  
  public int getQuantity() 
  {
    return quantity;
  }
  
  public void setQuantity(int quantity) 
  {
    this.quantity = quantity;
  }

  public boolean equals(Object obj) 
  {
    return obj instanceof ShoppingCartItem &&
               equals((ShoppingCartItem)obj);
  }

  public boolean equals(ShoppingCartItem that) 
  {
    return this.book == that.book;
  }
}

⌨️ 快捷键说明

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