I have this class called Food
.
Inside of food is an enum FoodType
as so:
public class Food {
public enum FoodType {
STRAWBERRY, COOKIE, CHILLI, APPLE, BURGER, HOTDOG, PIZZA, LEMON
}
FoodType foodType;
...
}
and in my constructor for food then I have this:
public Food(Vector2 position) {
...
this.foodType=generateFoodType();
}
Where generateFoodType
will randomly return one of the values from my enum.
The problem I am having is that certain other properties of a food will depend on its foodtype (size for example). This forces me to constantly check what the foods type is before setting its properties and I find myself constantly writing switch statements and just making things look like a total mess.
I have thought about making subclasses of Food
instead of using an enum but I'm wondering if anyone can see another way, as I could potentially end up with a lot of classes if I do this.