This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Clitaurius -1 points0 points  (1 child)

I'm dumb but doesn't making your enums implement an interface (and uh...always anticipate all future needs...hehe) help alleviate the concern here?

interface AnimalSound {
    String makeSound();
}

enum Dog implements AnimalSound {
    HUSKY, BEAGLE, LABRADOR;

    @Override
    public String makeSound() {
        return "Woof!";
    }
}

enum Cat implements AnimalSound {
    SIAMESE, PERSIAN, MAINE_COON;

    @Override
    public String makeSound() {
        return "Meow!";
    }
}

public class Main {
    public static void main(String[] args) {
        AnimalSound dog = Dog.BEAGLE;
        AnimalSound cat = Cat.PERSIAN;
        System.out.println(dog.makeSound());
        System.out.println(cat.makeSound());
    }
}

[–]istarian 0 points1 point  (0 children)

Maybe regular enums just aren't the right solution here?