Что еще на что проверить? не проходит валидация по второму пункту. Проверяла и с налом одним и с двумя и в разных объектах, все работает.
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 o) {
if (this == o) return true;
if (o == null) return false;
if (!(o instanceof Iphone)) return false;
Iphone phone = (Iphone) o;
if (this.price != phone.price) return false;
if (this.model == null) {
if (phone.model == null) {
if (this.color == null) return phone.color == null;
} else return false;
} else if (this.color == null) return phone.color == null;
if (!(this.model.equals(phone.model))) return false;
return this.color.equals(phone.color);
}
public static void main(String[] args) {
Iphone iphone1 = new Iphone("X", "Balck", 999);
Iphone iphone2 = new Iphone("X", "Balck", 999);
System.out.println(iphone1.equals(iphone2));
}
}