[Solved] Assigning Variable Types to numbers java


Your hasAnimals method needs to return a boolean value i.e. true or false based on the value of the type variable.

You’re .. kind of on the right track, but you’re not honoring the requirements of the method. It shouldn’t print anything, and it shouldn’t return type because type is an int and not the boolean that is required.

public boolean hasAnimals() {
    if(type == 1) {
        return true; // aquarium has animals
    } else if (type == 2) {
        return true; // zoo has animals
    } else {
        return false;
    }
}

Think carefully about what a method is called, and what it should do. This method is just a way to answer a yes/no question.

2

solved Assigning Variable Types to numbers java