Question: In a school, it is required to create a pick-up program in which each child is allowed to be picked up by one of his parents and at most one emergency contact. To do so, it is required to design 4 classes
- Dad Class: which includes Dad’s first name, last name, and phone number.
- Mon Class: which includes Dad’s first name, last name, and phone number.
- Emergency Contact class: Which includes the contact’s first name, last name, phone number and whether this contact is allowed to pick-up the child or not
- Child Class: Which will inherit all the previous data from the previous 3 classes, in addition to his name and grade. The Child class will also have a method called print_child_pickup_info to print a summary of the child name, along with his parents’ names, the emergency contact name, and whether is he allowed to pick up the child or not.
Here is my code. There is a problem with the line:
super().__init__(firstName, lastName, phone)
EmergencyContact.__init__(pickup)`
says that phone and pickup have an "unresolved reference"
Full code:
class Dad():
def __init__(self, firstName, lastName, phone):
self.firstName = firstName
self.lastName = lastName
self.phoneNumber = phone
class Mom():
def __init__(self, firstName, lastName, phone):
self.firstName = firstName
self.lastName = lastName
self.phoneNumber = phone
class EmergencyContact():
def __init__(self, firstName, lastName, phone, pickup):
self.firstName = firstName
self.lastName = lastName
self.phoneNumber = phone
self.pickup = pickup
#Inheritance
class Child(Dad, Mom, EmergencyContact):
def __ini__(self, firstName, lastName, grade):
self.CfirstName = firstName
self.ClastName = lastName
self.Cgrade = grade
super().__init__(firstName, lastName, phone)
EmergencyContact.__init__(pickup)
def print_child_pickup_info(self,D,M,EC):
print(self.CfirstName,self.ClastName)
print("Father Name:", D.firstName, D.lastName)
print("Mother Name:", M.firstName, M.lastName)
print("Emergency Contact Name:", EC.firstName, EC.lastName)
print("Can pick:", EC.pickup)