modification code given help please
Please modify the given code called: Person, Employee and Student classes. They are below instructions!
Add a custom exception classes for an invalid age (InvalidAge),years worked (InvalidYearsWorked) and units completed(InvalidUnits).
the only code not attached is student.py and that will be provided with a screenshot, please do not implement your code and copy paste the code that is given.
Valid age is 0 through 120.
Valid years worked is from 0 through 75.
Valid units is from 0 through 200.
1) Modify the setter methods in Person, Student and Employee as needed to raise an exception for an invalid age, invalid years worked and invalid number of units.
2) Modify the PersonTest application to catch these exceptions. Make your error messages informative. Remember to keep the generic exception as the last one.
3) Test your application with both valid and invalid data and ensure your program responds appropriately.
PERSON CLASS CODE:
class Person:
# custom constructor. Constructors are named __init__()
def __init__ (self, name, address, age):
# set the variables
# note the single underscore _ before the variable name makes them protected
self._name = name
# note we call the setter method here
self._address = address
self._age = age
# getter and setter methods for the various properties
def get_name(self):
return self._name
def set_name(self, name):
self._name = name
def get_address(self):
return self._address
def set_address(self, address):
self._address = address
def get_age(self):
return self._age
def set_age(self, age):
self._age = age
# instance method
def to_string(self):
return “Name: ” + self._name + ” Address: ” + str(self._address) + ” Age: ” + self._age
———————————————————————–
PERSON CODE:
from Employee import Employee
# import the Student Class
from Student import Student
name = input(“Enter name: “)
address = input(“Enter address: “)
age = input(“Enter age: ” )
job_skills = input(“Enter job skills: “)
years_worked = input(“Enter years worked: “)
major = input(“Enter major: “)
units_completed = input(“Enter units completed: “)
# create an instance of an employee
my_employee = Employee(name, address, age, job_skills, years_worked)
# create an instance of a student
my_student = Student(name, address, age, major, units_completed)
# invoke the to_sting() method and display everything
print(my_employee.to_string() )
print(my_student.to_string() )
———————————————————————–
EMPLOYEE:
class Employee(Person):
# custom constructor. Constructors are named __init__()
def __init__ (self, name, address, age, job_skills, years_worked):
# we are overriding the Person constructor so call the inherited constructor
super().__init__(name, address, age)
self._job_skills = job_skills
self._years_worked = years_worked
# getter and setter methods for the various properties
def get_job_skills(self):
return self._job_skills
def set_job_skills(self, job_skills):
self._job_skills = job_skills
def get_years_worked(self):
return self._years_worked
def set_years_worked(self, units_years_worked):
self._years_worked = years_worked
# instance method
def to_string(self):
return super().to_string() + ” Job Skills: ” + self._job_skills + ” Years Worked: ” + self._years_worked

