Course Enrollment System for an LMS
You are tasked with building a simple Course Enrollment System for an LMS. The system should handle students enrolling in courses, as well as the ability to manage course capacities.
Your goal is to implement the following functionality:
1. Create Courses: Each course has a name, a capacity (maximum number of students allowed), and a list of enrolled students.
2. Create Students: Each student has a name and can enroll in multiple courses.
3. Enroll Students in Courses: A student can enroll in a course if the course has available spots. If a course is full, the enrollment should fail with an appropriate error message.
4. Check Enrollment: A student should not be allowed to enroll in the same course twice. Attempting to do so should return an error message.
5. Drop a Course: A student can drop a course they are enrolled in, freeing up a spot in the course for other students.
6. Enrollment Summary: After enrolling or dropping, return the number of remaining spots in the course.
Requirements:
1. Course Class:
• Should store the course name, the total capacity, and a list of enrolled students.
• The enroll(student) method should check if the course has spots available and whether the student is already enrolled. If so, add the student to the course; otherwise, return an appropriate message.
• The drop(student) method should allow a student to drop the course, freeing up a spot.
2. Student Class:
• Should store the student’s name and a list of courses they are enrolled in.
• The enroll_in_course(course) method should enroll the student in a course if they are not already enrolled and if there are available spots.
• The drop_course(course) method should allow the student to drop the course.
3. Edge Cases:
• Ensure a student cannot enroll in the same course twice.
• Ensure a student cannot drop a course they are not enrolled in.
• Ensure course capacity is respected during enrollments and drops.