logo CodeStepByStep logo

Date

Language/Type: JavaScript classes

Write a "class" (a constructor function and methods, etc.) of objects named Date that 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 methods:

member name description
new Date(m, d) constructs a new date representing the given month and day
daysInMonth() returns the number of days in the month stored by your date object
getDay() returns the day
getMonth() returns the month
nextDay() advances the Date to the next day, wrapping to the next month and/or year if necessary
toString() returns a string representation such as "07/04"

You should define the entire class including the class heading, the private fields, and the declarations and definitions of all the public methods and constructor.

Class: Write a complete JavaScript 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.