Demonstrate use OOP principles, data structures and file handling operations to carry out the following tasks.
a) Define a class named PERSON, with child classes named DAUGHTER and SON who also have derived classes named GRANDSON and GRANDDAUGHTER respectively. All children classes have derived genetic features and skills from PERSON.
Create 5 methods for getting and setting genetic features, setting and getting skills and demonstrate the concept of polymorphism.
b) Modify the answer in a) and show how the PERSON features are captured in a file called person.txt. Also create another method to read from the file person.csv and store the data in a list called persondata.
Clearly show how exceptions are handled in year program.
class Person:
def __init__(self, name):
self.name = name
def say_hi(self):
print("Hello,", self.name)
class Son(Person):
pass
class Daughter(Person):
pass
with open("input.txt", 'r') as reader:
print(reader.read())
Comments
Leave a comment