package en.codegym.task.pro.task10.task1010;
import java.util.Objects;
/*
Two iPhones
*/
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(Iphone one){
if(this==one)
return true;
if(this==null)
return false;
if(this.getClass()== one.getClass()){
Iphone other = (Iphone) one;
return model.equals(other.model) && color.equals(other.color)
&& price==other.price;
}else
return false;
}
public static void main(String[] args) {
Iphone iphone1 = new Iphone("X", "White", 999);
Iphone iphone2 = new Iphone("X", "White", 999);
System.out.println(iphone1.equals(iphone2));
}
}
package en.codegym.task.pro.task10.task1010;
import java.util.Objects;
/*
Two iPhones
*/
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(Iphone one){
if(this==one)
return true;
if(this==null)
return false;
if(this.getClass()== one.getClass()){
Iphone other = (Iphone) one;
return model.equals(other.model) && color.equals(other.color)
&& price==other.price;
}else
return false;
}
public static void main(String[] args) {
Iphone iphone1 = new Iphone("X", "White", 999);
Iphone iphone2 = new Iphone("X", "White", 999);
System.out.println(iphone1.equals(iphone2));
}
}