Without going into detail. I have structure like this:
class someClass(m):
def __init__(self):
if m == 1:
self.mode1()
elif m == 2:
self.mode2()
elif m == 3:
self.mode3()
.....
elif m == 10:
self.mode10()
It's a class with different operating modes. Passing variable m
to the class I want to set mode of operation running corresponding method of class. Is there way to do this more elegant and get rid of the 'if' statements? May be there is some design pattern for this specific case?
Aucun commentaire:
Enregistrer un commentaire