Home > front end >  How would I complete the following IF statement?
How would I complete the following IF statement?

Time:04-26

Working on a large body of code where I have this method:

    public boolean equals(String aClaim) {
    boolean isEqual = false;
    if (...) {
        isEqual = true;
    }
    return isEqual;
}

I want to code a method equals() which returns a boolean and accepts a string aClaim as a parameter. Then declare a boolean isEqual, which is set to false. Finally, I want to set isEqual to true when three other variables in other methods, String insured, double homeInsVal, and double richter are the same for this method's calling object and the comparison object.

What do I put within the if statement in order to satisfy these instructions? I'm having trouble with the fact that these variables are of different types.

CodePudding user response:

public boolean testFunction(boolean isEqual) {

if (isEqual) {
    // Action block true
}else{
  // false block

}

}

CodePudding user response:

I think that this is not the best approach but assuming your others variables are global in relation to your method you can convert the Doubles variables as showing here.

Then you can put this expression in your if statement:

if(aClaim.equals(insured) && aClaim.equals(homeInsValAsString) && aClaim.equals(richterAsString)) {
  • Related