Starting from:

$30

CSCI161L Assignment 10 -Solved


Define a class Person and there are two sub-classes Student and Employee, which are inherited 
from the parent class Person. Employee class again has two subclasses Staff and Faculty. 
The common attributes for all of them includes ID, Name, Address, Phone_Number and 
Email_Id. The Student class has additional attributes: Class_Status (Undergraduate or graduate) 
and Major. The Employee class has additional attributes Date_of_Joining, Department and 
Salary. The child class of Employee - Faculty has additional attributes Title and Room_No, 
while Staff class has Title. The relationship between these classes and their attributes is shown in 
the Figure 1. (Note: The figure is not a UML diagram and is used here to show the class 
relationship.) 
Figure 1: Relationship between different classesCSCI 161L 
Write a Python code to create Person, Student, Employee, Staff and Faculty classes. Define 
the corresponding attributes in each class with inheritance. The attributes such as ID, Name, 
Address, Phone_Number and Email_ID should be defined in the class Person. For any other 
class these attributes should be inherited from class Person. 
The main program should call a function called menu (). The menu () should have the following 
options. 
1. Add a Student Details 
2. Add a Faculty Details 
3. Add a Staff Details 
4. Exit 
Add a Student details should ask the user to input student's Name, Id, Address, Phone_Number, 
Email_Id, Class_Status (undergraduate or graduate) and Major of study. The entered details 
should be stored in a file called "Student.txt". It can also be displayed in the terminal once the 
user enters the details (optional). 
Similarly, selecting option 2 should ask the user to input Faculty's Name, Id, Address, 
Phone_Number, Email_Id, Department, Date_of_Joining, Salary, Faculty_Title and 
Faculty_Room_No. The details entered should be written to a file "Faculty.txt". 
Similarly, add a Staff details should ask the user to input Staff's Name, Id, Address, 
Phone_Number, Email_Id, Department, Date_of_Joining, Salary, Staff_Title. The entered details 
should be written to a file "Staff.txt" 
Use class methods called read_data (), to read the data from the user and output_data (), to 
display the data read and output the data into a file. The program should generate three output 
files "Student.txt", "Faculty.txt" and "Staff.txt". Each file should contain all the details entered 
by the user. 
The program should use menu to choose among the options. For example, If the user selects 
option-1 four times and option-2 three times, and entered the details, the file "Students.txt" 
should contain four records and "Faculty.txt" should contain three records. Only way to exit from 
the program is through option 4. 
Note: 
For this lab, students are not required to submit the output files. As while running your code, the 
file should automatically be generated.CSCI 161L 
Sample Output: 
1. Student Details 
2. Faculty Details 
3. Staff Details 
4. Exit 
Enter an option: 1 
Entering Student Details… 
Enter the name: abc 
Enter the ID: 1001 
Enter the Address: Grand Forks, ND 
Enter Phone Number: 7012345656 
Enter Email ID : abc@gmail.com 
Enter ‘U’ for Undergrad and ‘G’ for Graduate: U 
Enter the major of study: CS 
abc 1001 Grand Forks, ND 7012345656 abc@gmail.com U CS 
1. Student Details 
2. Faculty Details 
3. Staff Details 
4. Exit 
Enter an option: 2CSCI 161L 
Note: 
1. The attributes Name, ID, Address, Phone_Number and Email_ID should be defined 
from the class Person. All other classes should inherit these attributes from class 
Person. Also, the attributes Department, Salary and Date_of_Joining should be 
defined from class Employee. The child classes (Faculty and Staff) of Employee 
should inherit these attributes. 
2. Each output file (Student.txt, Staff.txt and Faculty.txt) should contain all the data 
entered by the user. 
3. No need to submit output txt files. Only source code is necessary. 
Instructions: 
• Preferred programming environment: 
o OS 
: Linux (Mint) 
o Interpreter : Python 3 (not Python 2) 
o Editor 

More products