class Patient(object):
'''
Attributes
name = Patient name
age = Patient age
conditions = Existing patient's conditions
'''
status='patient'#-----------class variable-------
def __init__(self,name,age):
self.name=name
self.age=age
self.conditions=[]
def get_details(self):
print(f'Patient record: {self.name}, {self.age} years.'\
f'Current information: {self.conditions}.')
def add_info(self,information):
self.conditions.append(information)
x=Patient('Yash',21)
y=Patient('Raj',19)
class Infant(Patient):
def __init__(self,name,age):
self.vaccinations=[]
super().__init__(name,age);
def add_vac(self,vaccine):
self.vaccinations.append(vaccine)
def get_details(self):
print(f'Patient record: {self.name}, {self.age} years.\
Patient has had {self.vaccinations} vaccines.\
Current information: {self.conditions}.\
{self.name} IS AN INFACT, HAS HE HAD ALL HIS CHEAKS?')
ash=Infant('Yash',21)
ash.add_vac('MMR')
print(ash.get_details())
это только для sh экземпляра ok, x, y - другой экземпляр.