Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Instructor class (1.5 pts) Implement the Instructor class to initialize an instance as follows: The instructor's name should be stored in the name attribute,

 The Instructor class (1.5 pts) Implement the Instructor class to initialize an instance as follows: The instructor's name should be stored in the name attribute, and the list of courses the instructor teaches should be stored in the courses attribute. The list of courses is initially empty when a new Instructor object is created. Instructor name: str courses: list get_name() -> str set_name(new_name): str get_courses() -> list remove_course: str add_course: str Class diagram for Instructor get_name(self) Returns the name of the instructor. set_name(self, new_name): Sets the name of the instructor to the specified new_name. Method performs the update only when new_name is a non-empty string. get_courses(self): Returns the list of courses taught by the instructor. remove_course(self, course): Removes the specified course from the list of courses taught by the instructor, if it exists in the list. add_course(self, course): Adds the specified course to the list of courses taught by the instructor, if it is not already in the list. REMINDER: As you work on your coding assignments, it is important to remember that passing the examples provided does not guarantee full credit. While these examples can serve as a helpful starting point, it is ultimately your responsibility to thoroughly test your code and ensure that it is functioning correctly and meets all the requirements and specifications outlined in the assignment instructions. Failure to thoroughly test your code can result in incomplete or incorrect outputs, which will lead to deduction in points for each failed case. Create additional test cases and share them with you classmates on Teams, we are in this together! 90% > Passing all test cases 10% > Clarity and design of your code Examples: >>> t1= Instructor('John Doe') >>> t1.get_name() 'John Doe' >>> t1.get_courses() [] >>> t1.add_course('MATH140') >>> t1.get_courses() ['MATH140'] >>> t1.add_course('STAT100') >>> t1.get_courses() ['MATH140', 'STAT100'] >>> t1.add_course('STAT100') >>> t1.get_courses() ['MATH140', 'STAT100'] >>> t1.remove_course('MATH141') >>> t1.get_courses() ['MATH140', 'STAT100'] >>> t1.remove_course('MATH140') >>> t1.get_courses() ['STAT100']

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_2

Step: 3

blur-text-image_3

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

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Algorithms questions

Question

2. What is the evidence that taste is not sufficient for satiety?

Answered: 1 week ago