Question: This is on a python 3 the program should implement the following classes: class Date An instance of this class describes a date. Attributes :
This is on a python 3 the program should implement the following classes:
class Date
An instance of this class describes a date.
Attributes: These should include:
the canonical representation of the date
the associated events (a collection of strings, e.g., a list or set).
Methods: These should include:
__init__(self, date, event), where date is the canonical representation of the date and event is a string for an event
Getter methods for the attributes
add_event(self, event), where event is a string for an event; this method adds event to the collection of events for a Date object
__str__(self), which returns a string representation of a Date object
class DateSet
An instance of this class describes a collection of dates.
Attributes: These should include:
a dictionary of Date objects. (Consider what might you use as keys.)
Methods: These should include:
__init__(self), which creates an empty dictionary to hold Date objects
add_date(self, date), where date is a date object; this method adds date to the collection of dates
__str__(self), which returns a string representation of a DateSet object
Additionally, you will need code for the following:
To read in an input file name (use input() without arguments), read a series of operations from this file (see Input Formats above), and process them as specified under Expected Behavior above. You can put this code in a function that is not within any class (just like main()).
To convert a date string to canonical format. You can put this code in a function that is not within any class (just like main()).
Your program should be appropriately modularized. In particular, other than the code mentioned above for processing input and converting dates to their canonical form, your code should be placed in methods in the appropriate class.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
