здравствуйте, помогите пожалуйста, заранее спасибт. не пускает второй пункт мой код. Уже кучу ифов использовал, тесты проходит. может не всё тесты делаю
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 String getModel(){
return model;
}
public String getColor(){
return color;
}
public int getPrice(){
return 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.getModel() == null || iphone.getModel() == null) {
if(this.getModel() == null && iphone.getModel() == null) {
if(this.getColor() == null || iphone.getColor() == null) {
if(this.getColor() == null && iphone.getColor() == null) {
if(this.getPrice() == 0 || iphone.getPrice() == 0) {
if(this.getPrice() == 0 && iphone.getPrice() == 0) {
return true;
} else {
return false;
}
} else {
if (this.getPrice() == iphone.getPrice()){
return true;
} else {
return false;
}
}
} else {
return false;
}
} else {
if(this.getColor().equals(iphone.getColor())) {
if(this.getPrice() == 0 || iphone.getPrice() == 0) {
if(this.getPrice() == 0 && iphone.getPrice() == 0) {
return true;
} else {
return false;
}
} else {
if (this.getPrice() == iphone.getPrice()) {
return true;
} else {
return false;
}
}
} else {
return false;
}
}
} else {
return false;
}
}
if(this.getColor() == null || iphone.getColor() == null) {
if(this.getColor() == null && iphone.getColor() == null) {
if(this.getPrice() == 0 || iphone.getPrice() == 0) {
if(this.getPrice() == 0 && iphone.getPrice() == 0) {
return true;
} else {
return false;
}
} else {
if (this.getPrice() == iphone.getPrice()){
return true;
} else {
return false;
}
}
} else {
return false;
}
} else {
if(this.getColor().equals(iphone.getColor())) {
if(this.getPrice() == 0 || iphone.getPrice() == 0) {
if(this.getPrice() == 0 && iphone.getPrice() == 0) {
return true;
} else {
return false;
}
} else {
if (this.getPrice() == iphone.getPrice()) {
return true;
} else {
return false;
}
}
} else {
return false;
}
}
//---------------------------
}
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));
}
}