package lin.sxt;
class Cat
{
private int color;
private int hight;
private int weight;
public Cat(){}
public Cat(int color,int hight,int weight)
{
this.color = color;
this.hight = hight;
this.weight = weight;
}
public boolean equals(Object obj)
{
if(obj == null)
return false;
else
{
if(obj instanceof Cat)
{
Cat c =(Cat)obj;
if(c.color==this.color && c.hight==this.hight && c.weight==this.weight)
return true;
}
}
return false;
}
}
public class TestEquale {
public static void main(String[] args) {
Cat a = new Cat();
Cat b = new Cat();
System.out.println(a.equals(b));
Cat x = new Cat(1,2,3);
Cat y = new Cat(1,2,3);
System.out.println(x.equals(y));
System.out.println(a.equals(x));
}
}