logo CodeStepByStep logo

Date

Language/Type: Python classes

Write a class named Date where each object remembers information about a month and day. Ignore leap years and don't store the year in your object. You must include the following public members:

member name type description
Date(month, day) constructor constructs a new date representing the given month and day
d.month property property to get/set the month
d.day property property to get/set the day
d.advance() method advances to the next day, wrapping to the next month and/or year if necessary
d.days_in_month() method returns the number of days in the month stored by your date object
d == other method returns True if the two dates have the same state
str(d) method returns a string representation such as "7/4" for July 4

You should define the entire class including the class heading, the private instance variables, and the declarations and definitions of all the public member functions and constructor.

Class: Write a complete Python class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.