Instance Attributes and Properties Protect the data to ensure encapsulation. Implement properties for al instance attributes unless noted.
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...
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.

Transcribed Image Text:### University Class Diagram
This represents a UML (Unified Modeling Language) class diagram for a `University` class. It includes the class attributes and methods:
#### Attributes:
- **name : string**
- Represents the name of the university as a string.
#### Methods:
- **__str__**
- Special method to return a string representation of the object.
- **add_undergrad(name, email, gpa)**
- Adds an undergraduate student with specified name, email, and GPA.
- **add_graduate(name, email, level)**
- Adds a graduate student with specified name, email, and academic level.
- **add_course(...)**
- Adds a course to the university. Parameters are not specified in this diagram.
- **remove_student(name) : list**
- Removes a student by name and returns a list of remaining students.
- **get_students(name, id, email) : list**
- Retrieves a list of students based on name, ID, and email.
- **get_courses(subject, number, title) : list**
- Retrieves a list of courses based on subject, course number, and title.
- **enroll_student(id, subject, number)**
- Enrolls a student in a course identified by ID, subject, and course number.
- **enrollment_report() : dict**
- Generates and returns an enrollment report as a dictionary.
![- **University**:
- Represents 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 for creating the objects:
- `add_undergrad(name, email, gpa)` and `add_graduate(name, email, level)` methods will create and add students to the university. A 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's 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 optionally 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 whose 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 the key is a string representing the course (concatenation of subject and number - formatted in 4 digits 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)`](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F1d722143-f111-402d-9194-370f4c36bfd7%2F1abdc57b-20be-4032-be49-9338f09ca682%2F6gcvilh_processed.png&w=3840&q=75)
Transcribed Image Text:- **University**:
- Represents 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 for creating the objects:
- `add_undergrad(name, email, gpa)` and `add_graduate(name, email, level)` methods will create and add students to the university. A 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's 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 optionally 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 whose 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 the key is a string representing the course (concatenation of subject and number - formatted in 4 digits 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)`
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Recommended textbooks for you

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY