Faculties and Students

Faculties and Students

Details of the Faculty & students to be maintained by a college for easy access. Develop a program to store the information.
Create a base class named Person with instance member’s(name,age,dept) and a constructor to initialize the data member’s
Create a base class named Student with instance member(sid) and a constructor to initialize the data member
Create a base class named Faculty with instance member(fid) and a constructor to initialize the data member
Create a dervied class StudentMember which inherits the Person and Student class, and holds all the properties of the both Person and Student class and a method display to display all details about student.
Create a dervied class FacultyMember which inherits the Person and Faculty class, and holds all the properties of the both Person and Faculty class and a method display to display all details about Faculty.

In the Main class get the input of the member type, details of member based on member type, and display the member details based on member type.  
if member type is Student create an object for StudentMember class and using the same display the details of student by invoking display function in StudentMember class.
if member type is Faculty create an object for FacultyMember class and using the same display the details of faculty by invoking display function in FacultyMember class.

Note:

Strictly follow the naming conventions for variables and functions as specified in the problem description.

The StudentMember class object should be s_account_obj

The FacultyMember object should be f_account_obj

All the attribute values should be user inputs and store those values into the variables with the name:

name for storing name of staff/student.

age for storing age of staff/student.

dept for storing department of staff/student.

id for storing id of staff/student.

Sample Input 1:
1.Student member
2.Faculty member
Enter the choice
1
Enter the Details:
Name
Ashik
Age
19
Department
CSE
Id
S1001
Sample Output 1:
Student Details
Ashik
19
CSE
S1001

Sample Input 2:
1.Student member
2.Faculty member
Enter the choice
2
Enter the Details:
Name
Anwar
Age
29
Department
EEE
Id
F1009
Sample Output 2:
Faculty Details
Anwar
29
EEE
F1009

Code :-

class Person:
    def __init__(self,name,age,dept):
        self.name=name
        self.age=age
        self.dept=dept
    
    def get_name(self):
        return self.name
    def get_age(self):
        return self.age
    def get_dept(self):
        return self.dept
    def display(self):
        print(self.get_name()+"\n"+str(self.get_age())+"\n"+self.get_dept())
        
class Student:
    def __init__(self,sid):
        self.sid=sid
    
    def get_sid(self):
        return self.sid
    
    def display(self):
        print(self.get_sid())

class Faculty:
    def __init__(self,fid):
        self.fid=fid
    
    def get_fid(self):
        return self.fid
    def display(self):
        print(self.get_fid())

class StudentMember(Person,Student):
    def __init__(self,name,age,dept,sid):
        Person.__init__(self,name,age,dept)
        Student.__init__(self,sid)
    def display(self):
        Person.display(self)
        Student.display(self)
    

class FacultyMember(Person,Faculty):
    def __init__(self,name,age,dept,fid):
        Person.__init__(self,name,age,dept)
        Faculty.__init__(self,fid)
    def display(self):
        Person.display(self)
        Faculty.display(self)
    
    
    
print("1.Student member\n2.Faculty member")
choice=int(input("Enter the choice\n"))
print("Enter the Details:")
name=input("Name\n")
age=int(input("Age\n"))
dept=input("Department\n")
id=input("Id\n")

if choice==1:
    s_account_obj=StudentMember(name,age,dept,id)
    print("Student Details")
    s_account_obj.display()
elif choice==2:
    f_account_obj=FacultyMember(name,age,dept,id)
    print("Faculty Details")
    f_account_obj.display()

Leave a Comment

Your email address will not be published. Required fields are marked *

x