So for instance you have an object with a type for sounds, and based on the enum a particular function will do play a different sound depending on the type
public enum ObjectType{
Type1,
Type2,
Type3
}
public class Object{
public ObjectType type;
public Sound sound;
private void DoThing(){
if(type.Type1){
sound = Load("sounds/sound1");
}
if(type.Type2){
sound = Load("sounds/sound2");
}
//etc...
}
}
I guess my question is, when this enum will grow larger in size into the tens or hundreds, what's the best practice to organize and test against the enum to return another value?
Should I be using a switch case rather than a bunch of if tests? Mostly just regarding organization, these functions aren't really resource heavy and won't be using a lot of computation, so performance isn't really my concern, mostly readability.
Aucun commentaire:
Enregistrer un commentaire