Create a class called "Course" with attributes "department" and "number" with a default constructor that initializes to "DAT" as the department and "51" as the number. Define functions "setDepartment"...

1 answer below »

Create a class called "Course" with attributes "department" and "number" with a default constructor that initializes to "DAT" as the department and "51" as the number.


Define functions "setDepartment" and "setNumber" for the user.


Add an overloaded operator so the user can easily see the content of the object by typing its name.


Use only what was discussed in class. Use of any other code found online or from another party, such as a tutor, will be considered cheating.


You can discuss homework with classmates, but the work you submit must be your own, not copied from another student.


Here is a sample output:



>>> a=Course()



>>> a


DAT51



>>> b=Course('ART','11')



>>> b


ART11



>>> b.setDepartment('MATH')



>>> b.setNumber(10)



>>> b


MATH10

Answered Same DayOct 06, 2021

Answer To: Create a class called "Course" with attributes "department" and "number" with a default constructor...

Kshitij answered on Oct 07 2021
131 Votes
class course:
department = ""
number = ""
def __init__(self, f="DAT", s="51"):
self.department = f
self.number = s
def __str__(self) -> str:
return self.department + self.number
def setDepartment(self, dept):
self.department = dept
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here