item.java

来自「项目是实现网络购物功能」· Java 代码 · 共 63 行

JAVA
63
字号
package com.tarena.shoppingcart.model;

import java.io.Serializable;

public class Item implements Serializable {
	private Integer id; 
	private Product product;
	private int number;
	private double cost;
	
	public Item(){
		
	}

	public double getCost() {
		return cost;
	}

	public void setCost(double cost) {
		this.cost = cost;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public int getNumber() {
		return number;
	}

	public void setNumber(int number) {
		this.number = number;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	@Override
	public boolean equals(Object o) {
		if(o==null) return false;
		if(o==this) return true;
		if(!(o instanceof Item)) return false;
		Item i = (Item)o;
		if(i.id!=null || this.id!=null) return this.id.equals(i.id);
		if(i.product!=null || this.product!=null) return this.product.getId().equals(i.product.getId());
		return true;
	}

	@Override
	public int hashCode() {
		return id==null ? 0 :id.hashCode();
	}

}

⌨️ 快捷键说明

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