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

📄 item.java

📁 shoppingCar 购物车
💻 JAVA
字号:
package com.tarena.shoppingcar.entity;import java.io.Serializable;public class Item implements Serializable {	private static final long serialVersionUID = -5818580061201193904L;	private int id;	private Product product = new Product();	private int amount;	@SuppressWarnings("unused")	private double cost;	public int getAmount() {		return amount;	}	public void setAmount(int amount) {		this.amount = amount;	}	public double getCost() {		return this.product.getPrice()*this.amount;	}	public void setCost(double cost) {		this.cost = cost;	}	public int getId() {		return id;	}	public void setId(int id) {		this.id = id;	}	public Product getProduct() {		return product;	}	public void setProduct(Product product) {		this.product = product;	}	public void addProduct(Product product) {		if(this.product.equals(product)){			this.amount = this.amount + 1;			setCost();		}else{			this.product = product;			this.amount = 1;			this.cost = product.getPrice();		}	}		public void setCost() {		this.cost = this.product.getPrice()*this.amount;	}		@Override	public boolean equals(Object obj) {		if(obj.getClass() != this.getClass()){			return false;		}		Item item = (Item)obj;		if(this.product.getId() == item.product.getId()) {			return true;		}		return false;	}	@Override	public int hashCode() {		return this.id;	}}

⌨️ 快捷键说明

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