jeudi 20 décembre 2018

Making choice between inherience and enum

I have class Land:

class Land{
    double latitude;
    double longitude;
}

Land can be one of 3 types - Steepy, Plain, and Wet.

Now, should I create LandType enum:

enum LandType{
    STEEPY, PLAIN, WET
}

and, use it as a field in Land class?

Or, I should create 3 derived classes SteepyLand, PlanLand, WetLand from

Aucun commentaire:

Enregistrer un commentaire