Question
Concepts Focus on defining a Date and Event class from scratch. Suggestion: Use NotePad or WordPad Consider using NotePad or WordPad on your computer to
Focus on defining a Date and Event class from scratch.
Suggestion: Use NotePad or WordPad
Consider using NotePad or WordPad on your computer to write your code for this lab. Once you feel good about what you've written, then copy the code into your project. Doing this will help you seewhereyou might make mistakes on the exam!
You should write a main.cpp that testseachfeature of your class works as expected. You will need to submit your class declaration files, your class definition files, and your main.cpp file for this lab.
Date Class
We know you, as a Mines student, have a busy social life. Wouldn't it be great to have a program that helped you keep track of all your important dates (as in month, day, and year)? Write a Date class to represent this \"thing\" to the computer. What properties do you need to represent a date? Make these properties private to your class. (Again, you should knowwhyprivate makes sense; ask if you don't!) In all functions that modify data members, you should always ensure the values being set make sense. (You do not need to worry about leap years.) Also, use a private helper function wherever one makes sense. Functions you should include in your class:
- A default constructor that sets the date to 12/30/1950 (an extremely important date in our history).
- A parameterized constructor that allows a user to enter a new date, such as \"8,1,1876\" (another extremely important date in our history).
- Appropriate getter and setter functions. (Perhaps one setter function makes the most sense?)
- A private validate function that checks if the object is currently in a good state (e.g., months are 1-12, days are 1-31, year can't be negative, etc. Don't worry about having the correct number of days in a month or leap years.) and, if not, resets the date object to the default values. This function should be called byallfunctions that modify the date object.
- A boolean member function that returns whether thecalleeis earlier than thetargetdate argument passed.
Extra credit points possible if (1) your default constructor outputs a \"shout out\" that illustrates you understand the significance of 12/30/1950 and (2) your parameterized constructor outputs a \"shout out\" that illustrates you understand the significance of 8/1/1876.
Event Class
Now that we have a way to represent a calendar date, we need a way to make entries into a calendar. Create a new class called Event that contains a data member of type Date. In addition, add data members to track the event title and location. Functions you should include in your class:
- A default constructor that sets the date to a default date.
- A parameterized constructor that allows a user to enter a new date object, title, and location. The parameterized constructor should operate on a Date object and not on the individual month, day, year integer pieces.
- Appropriate getter and setter functions. The Date setter should operate on a Date object and no longer the individual month, day, year pieces.
- A print function that prints the details in the form: MM/DD/YYYY: Title (location).
Please help with this in C++ language only. Thank You!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started