....
package com.javarush.task.pro.task10.task1010;
import java.util.Objects;
/*
Два айфона
*/
public class Iphone {
private String model;
private String color;
private int price;
public Iphone(String model, String color, int price) {
this.model = model;
this.color = color;
this.price = price;
}
@Override
public boolean equals (Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof Iphone))
return false;
Iphone iphone = (Iphone) obj;
if (this.model == null)
return obj.model == null;
if (this.color == null)
return obj.color == null;
if (this.price == null)
return obj.price == null;
if (this.model.equals(obj.model) && this.color.equals(obj.color) && this.price.equals(obj.price))
return true;
}
}