вывод правильный но валидатору что-то не нравится
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;
}
public boolean equals(Object object) {
Iphone iphone1 = (Iphone) object;
if (!(object instanceof Iphone)) {
return false;
}
if (object == null) {
return false;
}
if (!this.model.equals(iphone1.model)) {
return false;
}
if (!this.color.equals(iphone1.color)) {
return false;
}
return this.price == iphone1.price;
}
public static void main(String[] args) {
Iphone iphone1 = new Iphone("X", "Black", 999);
Iphone iphone2 = new Iphone("X", "Black", 999);
System.out.println(iphone1.equals(iphone2));
}
}