Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(create) a Python project manage_course.Add a Python file course.py to this project.Define a class Course in this file.This class has three publicly accessible instance variables

(create) a Python project manage_course.Add a Python file course.py to this project.Define a class Course in this file.This class has three publicly accessible instance variables to store course code, maximum class size and enrollment.Define the following methods:

In this lab assignment, students will demonstrate the abilities to:

- design objects

- define classes

- create and use objects

- control accessibility to class members

PLEASE NO BREAK STATEMENTS OR IF TRUE STATEMENTS THANK YOU!!

(a)An __init__ method that accepts course code and maximum class size as arguments.Write statements in __init__ to store them in instance variables. Also (create) an instance variable to store enrollment and initialize it to 0.

(b)An add_student method to increase enrollment by one and display "One student added" if the course is not full.If the course is already full, make no change to enrollment and display "Course already full".This method has no argument other than self and has no return value.

(c)A drop_student method to decrease enrollment by one and display "One student dropped" if the course is not empty.If the course is empty, make no change to enrollment and display "Course is empty".This method has no argument other than self and has no return value.

The following class diagram shows the design of this class:

Course

+course_code: String

+max_size: Integer

+enrollment: Integer

+Course(course_code:String, max_size:Integer)

+add_student()

+drop_student()

Add a file manage_course_main.py to this project.This is the main module.(write) code to ask the user to enter course code and maximum class size of a course.Use the data provided by the user to (create) an instance of Course.(Write) a loop to manage this course.In the loop, ask the user to enter 1 for adding a student, 2 for dropping a student, 3 for displaying course info, or 0 for exit.If 1 is chosen, call the add_student method of the Course object and use a print statement to display updated enrollment.If 2 is chosen, call the drop_student method of the Course object and use a print statement to display updated enrollment.If 3 is chosen, display values stored in the Course object to show course code, maximum class size and enrollment.

The following shows a sample test run:

Enter course code: CSC121

Enter maximum class size: 2

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 1

One student added.

Enrollment: 1

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 2

One student dropped

Enrollment: 0

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 2

Course is empty.

Enrollment: 0

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 1

One student added.

Enrollment: 1

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 1

One student added.

Enrollment: 2

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 1

Course already full.

Enrollment: 2

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 3

Course code: CSC121

Maximum class size: 2

Enrollment: 2

Enter 1 for add student, 2 for drop student, 3 for course info, 0 for exit: 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions