Quote:If a user of this class wants to determine the mfg.year
Better to store the data in a dictionary IMHO. Have the key point to a list if you want to store more than the year.
class IPhone():
def __init__(self,ver):
self.ver = ver
self.ver_dic={'3G': 2007,
'3GS':2009,
'4': 2010,
'4s': 2011,
'5': 2012}
self.phone_factory()
def phone_factory(self):
if self.ver in self.ver_dic:
return self.ver_dic[self.ver]
else:
## Python returns None if there is no return
## so this is not necessary
return None