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

📄 buyitem.java

📁 巴巴运动网源码 传智博客出品 不全 一部分代码 可以参考
💻 JAVA
字号:
package com.itcast.bean;

import com.itcast.bean.product.ProductInfo;
import com.itcast.bean.product.ProductStyle;

public class BuyItem {
	/** 所购买的商品 **/
	private ProductInfo product;
	/** 购买数量 **/
	private int amount;
	
	public BuyItem(ProductInfo product) {
		this.product = product;
	}
	public BuyItem(ProductInfo product, int amount) {
		this.product = product;
		this.amount = amount;
	}
	public ProductInfo getProduct() {
		return product;
	}
	public void setProduct(ProductInfo product) {
		this.product = product;
	}
	public int getAmount() {
		return amount;
	}
	public void setAmount(int amount) {
		this.amount = amount;
	}
	
	@Override
	public int hashCode() {
		String buyitemid = product.hashCode()+ "-";
		if(product.getStyles().size()>0){
			buyitemid += product.getStyles().iterator().next().getId();
		}
		return buyitemid.hashCode();
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final BuyItem other = (BuyItem) obj;
		if (product == null) {
			if (other.product != null)
				return false;
		} else if (!product.equals(other.product))
			return false;		
		if(product.getStyles().size()!=other.product.getStyles().size()){
			return false;
		}
		if(product.getStyles().size()>0){
			ProductStyle style = product.getStyles().iterator().next();
			ProductStyle otherstyle = other.product.getStyles().iterator().next();
			if(!style.equals(otherstyle)) return false;		
		}		
		return true;
	}
	
}

⌨️ 快捷键说明

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