This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Enumerations / Lists of available types

No replies
edmondo1984
Joined: 2011-09-14,
User offline. Last seen 28 weeks 3 days ago.
Dear all,
I have an abstract  animal, and three concrete type of animals: dog, cat and pig. Each instance of one of these classes correspond to an existing animal, with his weight, his size, and all this kind of stuff.

I would like in some way to list all the available types of concrete animals, and returning  a list containing for each available subtype a description. I can create an enumeration, having one value corresponding to each subclass of animals. However, this force me to update my enumeration each time I add a new subclass of animal.

The classical case is for example a web application to store data about animals: first you would have to decide which kind of animal you want to add, then you get redirected to a specific page where you can fill the necessary data for that kind of animal.
Is there a better way to do this?


Thank you for your help
Best Regards

Edmondo



Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland