package edu.mama.ls16.homework;
//订单中没有卖家ID,以卖家名字作为唯一标识
public class Seller {
private String name;
public Seller (String name) {<br /> this.name = name;<br /> }
public String getName() {<br /> return name;<br /> }
//以sep为分隔符,将Seller内容拼接成字符串<br /> public String toString(String sep) {<br /> return this.name;<br /> }
//使用Map,重写equals和hasCode方法<br /> @Override<br /> public boolean equals(Object obj) {<br /> if(this==obj)<br /> return true; //地址相等<br /> if(obj instanceof Seller){<br /> Seller other=(Seller)obj;<br /> if(this.name.equals(other.name))<br /> return true; //名称相同<br /> }<br /> return false;<br /> }
@Override<br /> public int hashCode() {<br /> return this.name.hashCode();<br /> }
}