An Animal can be a Dog, Fish, Bird, etc
A Dog can be a Shepherd, Terrier, etc
A Fish can be a Guppy, Salmon, etc
getAnimal(InputStream) reads some input from the input stream and returns an object of type Animal.
A checking function repeatedly calls getAnimal and checks what kind of Animal is returned(Dog, Fish, etc), then checks the specific type of animal(Guppy, Salmon, etc), and does some computation.
How should the datatype Animal be implemented? An enum/struct/typedef/class? How then would I go about implementing the checking function? I was thinking of something like the following:
The syntax and case construct is slightly broken but I hope you get the idea.Code:Animal a = getAnimal(inputStream); switch (a) { case DOG: do something case SHEPERD: do something: case TERRIER: do something: case FISH: do something case GUPPY: do something: case SALMON: do something: .... }