A university is a very busy place with a lot of students and also a lot of employees to keep the system running perfectly. All people in the university have basic information like name, address, email and phone number. Employees at the university have extra information like employee-id and salary. There are also faculty and staff who are employees at the university. Each faculty has a designation and is assigned to a specific college and has number of courses taught. Each staff belongs to a specific department such as IT, HR etc. and has a designation at the department. Then, there are students who have the information such as Courses taken, GPA etc.
You are required to draw the UML Class diagram and create Python classes to represent the different types of people at a university. Identify the classes and the relationships between them. Implement the classes in Python. Create a separate test module where instances of the class are created, and the methods are tested by creating a list of different people at the university and displaying their information.
(DRAW UML AND CREATE PYTHON) WITH comments and screenshots please
Hey! here is my code and output with screen shorts... to appreciate my work please give positive feedback ...this code take so much time.....
Code:
# Base class
class Person:
name = ""
address = ""
email = ""
phone = 0
def __init__(self, pname, paddress, pemail, pphone):
self.name = pname
self.address = paddress
self.email = pemail
self.phone = pphone
# Function to display student details
def display(self):
print("Name : ", self.name)
print("Address : ", self.address)
print("Email : ", self.email)
print("phone no : ", self.phone)
# parent class for faculty and student child class
class Courses:
course_name = []
course_code = []
def __init__(self, c_name, c_code):
self.course_name = c_name
self.course_code = c_code
def display(self):
print("Course name : ", ",".join(self.course_name))
print("Course code : ", ",".join(self.course_code))
# parent class for Staff child class
class Department:
department_name = ""
def __init__(self, d_name):
self.department_name = d_name
def display(self):
print("Department name : ", self.department_name)
# parent class for student and staff child class
class College:
college_name = ""
college_code = 0
college_address = ""
def __init__(self, code, name, address):
self.college_code = code
self.college_name = name
self.college_address = address
def display(self):
print("College Code : ", self.college_code)
print("College name : ", self.college_name)
print("College Address : ", self.college_address)
# child class inherit person, course, college class
class Student(Person, Courses, College):
student_rn = 0
student_GPA = 0
def __init__(self, rollno, GPA, pname, paddress, pemail, pphone, c_name, c_code, code, name, address):
self.student_rn = rollno
self.student_GPA = GPA
Person.__init__(self, pname, paddress, pemail, pphone)
Courses.__init__(self, c_name, c_code)
College.__init__(self, code, name, address)
def display(self):
Person.display(self)
print("RollNo : ", self.student_rn)
print("Email : ", self.student_GPA)
Courses.display(self)
College.display(self)
# child class inherit person
class Employee(Person):
em_id = ""
em_salary = 0
def __init__(self, id, salary, pname, paddress, pemail, pphone):
Person.__init__(self, pname, paddress, pemail, pphone)
self.em_id = id
self.em_salary = salary
def display(self):
print("Employee id : ", self.em_id)
Person.display(self)
print(f"Employee salary : {self.em_salary} ")
# child class inherit Employee, course, college class
class Faculty(Employee, College, Courses):
faculty_designation = ""
def __init__(self, id, salary, pname, paddress, pemail, pphone, designation, c_name, c_code, code, name, address):
Employee.__init__(self, id, salary, pname, paddress, pemail, pphone)
Courses.__init__(self, c_name, c_code)
College.__init__(self, code, name, address)
self.faculty_designation = designation
def display(self):
Employee.display(self)
print("Faculty Designation : ", self.faculty_designation)
Courses.display(self)
College.display(self)
# child class inherit Employee, Department class
class Staff(Employee, Department, ):
staff_designation = ""
def __init__(self, id, salary, pname, paddress, pemail, pphone, designation, d_name):
Employee.__init__(self, id, salary, pname, paddress, pemail, pphone)
Department.__init__(self, d_name)
self.staff_designation = designation
def display(self):
Employee.display(self)
print("Staff Designation : ", self.staff_designation)
Department.display(self)
# main code that drive the program
if __name__ == '__main__':
print("********************Student Data***************************")
s1 = Student(515607217, 9, "shweta", "XYZ 1101", "[email protected]", 123456786, ["Computer Science"], ['127'], 156, "XYZE",
"E=123 ABC")
s1.display()
print("\n********************Faculty Member Data*************************")
f1 = Faculty(23024, 50000, "Mr. john smith", "ABCD 1101", "[email protected]", 9625487425, "Assistant Professor",
['Chemistry', 'Commerce'], ['458','890'], 156, "XYZE", "E=123 ABC")
f1.display()
print("\n********************Staff Member Data*************************")
staff1 = Staff(12085, 30000, "Mrs.Sina", "xyzs E-897", "[email protected]", 4578123695,
"Assistant", "IT")
staff1.display()
Output:-
UML Daigram:-
thanks............for any query related to code .....please ask me......and give positive Rating ...
Get Answers For Free
Most questions answered within 1 hours.