import java.util.*;
public class Digimon1{
private String name;
private int hitPoints;
private double attackSpeed;
public Digimon1(String name, int hitPoints, double attackSpeed){
this.name = name;
this.hitPoints = hitPoints;
this.attackSpeed = attackSpeed;
}
public String getName(){
return this.name;
}
public double getAttackSpeed(){
return this.attackSpeed;
}
public boolean equals(Object a){
Digimon1 o = (Digimon1) a;
if (this.name == o.getName() && this.attackSpeed == o.getAttackSpeed()){
return true;
}else{
return false;
}
}
public static void main(String[] args){
List <Digimon1> digimon = new ArrayList<>();
Digimon1 gatamon = new Digimon1("Gatamon", 500, 12.9);
digimon.add(gatamon);
Digimon1 agumon = new Digimon1("agumon", 53, 9.8);//agumon
digimon.add(gatamon);
Digimon1 agumon1 = new Digimon1("agumon", 53, 9.8);//agumon1
digimon.add(gatamon);
System.out.print(agumon.equals(agumon1));
}
}
So my codes equals method should output a "true, false, true" when 2 digimons have the same name and attackspeeed. But what i understand is that my equals can return if my object is true or or false. how do i return three boolean statments?