Design and implement a class dayType that implements the day of the week in a program. The class dayType should store the day, such as Sun for Sunday. The program should be able to perform the...

1 answer below »
Design and implement aclass dayTypethat implements the day of the week in a program. Theclass dayTypeshould store the day, such as Sun for Sunday. The program should be able to perform the following operations on an object of typedayType:a. Set the dat.b. Print the day.c. Return the day.d. Return the next daye. Return the previous dayf. Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add 4 days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday.g. Add the appropriate constructors.
It should be written in python
Answered Same DayAug 01, 2021

Answer To: Design and implement a class dayType that implements the day of the week in a program. The class...

Vibhav answered on Aug 01 2021
153 Votes
dayType/1.JPG
dayType/dayType.py
class dayType:
#Valid values for day
days = ['Sun','Mon
','Tue','Wed','Thu','Fri','Sat']

'''
Constructor
Check the provided argument is in valid day values or not, if not raise
exception
'''
def __init__(self, day):
if day in self.days:
self.day = day
else:
raise ValueError("Invalid day")

'''
If valid argument provided, set day, otherwise raise exception
'''
def setDay(self,...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here