Instance Attributes and Properties Protect the data to ensure encapsulation. Implement properties for al instance attributes unless noted.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Implement the class below in python3

  • Instance Attributes and Properties
    • Protect the data to ensure encapsulation.
    • Implement properties for al instance attributes unless noted.

 

University
- name : string
str
+ add_undergrad(name, email, gpa)
+ add_graduate(name, email, level)
+ add_course(.)
+ remove_student(name) : list
+ get_students(name, id, email) : list
+ get_courses(subject, number, title): list
+ enroll_student( id, subject, number)
+ enrollment_report(): dict
Transcribed Image Text:University - name : string str + add_undergrad(name, email, gpa) + add_graduate(name, email, level) + add_course(.) + remove_student(name) : list + get_students(name, id, email) : list + get_courses(subject, number, title): list + enroll_student( id, subject, number) + enrollment_report(): dict
• University:
• Represent the university which has students and courses.
• All properties are read only. Student and course lists cannot be retrieved by the clients.
• The university is responsible of creating the objects:
- add_undergrad(name, email, gpa) and add_graduate(name, email, level) methods will create and add students to the university. Student's id will be generated automatically on
the Student constructor. The data such as valid GPA values or valid Level value will be validated properly in each class properties methods.
· add_course(subject, number, title) will add a course. Will raise a ValueError exception if there is already a course with the same subject and number.
• get_students and get_courses
• will take optionaly any of the arguments and return a list of the objects students or courses respectively, that matches the search criteria.
· String-based attributes are not exact match but rather that the data contain that search string.
· e.g. get_students(email="john.doe") will return a list of students which emails have "john.doe" in it, such as "john.doe.smith@." "william.john.doe@.", etc.
· Clarification: objects (students/courses) should match all specified filters by the user. E.g. get_courses("CSCI", 3920) will return all courses that match both the subject and
number.
· Hint: use default arguments and lists and sets to make your code simple. Consider having a matching list per filter and then compute the intersection; initialization will be
critical for this to work.
• enroll_student(.) will take the student's id and the course's subject and number and will enroll the student to the course. Enrollment is kept at the student as a list of courses the
student is enrolled to.
• enrollment_report() will return a dictionary of the form key -> value, where key is a string representing the course (concatenation of subject and number - formatted in 4 digit with
leading zeros), and the value is a list of students enrolled to that course.
· e.g. "CSCI3920" -> [ stu1, stu2,..]
· Clarification: Only courses with enrolled students will appear in the result.
• remove_student(name) removes all the students that has that name, comparing with exact match but ignoring case. Will return the list of students removed (may be empty).
Transcribed Image Text:• University: • Represent the university which has students and courses. • All properties are read only. Student and course lists cannot be retrieved by the clients. • The university is responsible of creating the objects: - add_undergrad(name, email, gpa) and add_graduate(name, email, level) methods will create and add students to the university. Student's id will be generated automatically on the Student constructor. The data such as valid GPA values or valid Level value will be validated properly in each class properties methods. · add_course(subject, number, title) will add a course. Will raise a ValueError exception if there is already a course with the same subject and number. • get_students and get_courses • will take optionaly any of the arguments and return a list of the objects students or courses respectively, that matches the search criteria. · String-based attributes are not exact match but rather that the data contain that search string. · e.g. get_students(email="john.doe") will return a list of students which emails have "john.doe" in it, such as "john.doe.smith@." "william.john.doe@.", etc. · Clarification: objects (students/courses) should match all specified filters by the user. E.g. get_courses("CSCI", 3920) will return all courses that match both the subject and number. · Hint: use default arguments and lists and sets to make your code simple. Consider having a matching list per filter and then compute the intersection; initialization will be critical for this to work. • enroll_student(.) will take the student's id and the course's subject and number and will enroll the student to the course. Enrollment is kept at the student as a list of courses the student is enrolled to. • enrollment_report() will return a dictionary of the form key -> value, where key is a string representing the course (concatenation of subject and number - formatted in 4 digit with leading zeros), and the value is a list of students enrolled to that course. · e.g. "CSCI3920" -> [ stu1, stu2,..] · Clarification: Only courses with enrolled students will appear in the result. • remove_student(name) removes all the students that has that name, comparing with exact match but ignoring case. Will return the list of students removed (may be empty).
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY