CSCI161 Assignment 10 Solved

25.00 $

Category: Tags: , ,
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

Rate this product

Objective:

This assignment is intended to use class inheritance and file operation in Python

Assignment:
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 classes

CSCI 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 : [email protected]
Enter ‘U’ for Undergrad and ‘G’ for Graduate: U Enter the major of study: CS

abc 1001 Grand Forks, ND 7012345656 [email protected] U CS

  1. Student Details
  2. Faculty Details
  3. Staff Details
  4. Exit

Enter an option: 2

CSCI 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 : gedit or editor of your choice

  • The program is saved as a file with .py extension.
  • assignment10-xabsge.zip