CSCI 261 - Programming Concepts (C++)

Fall 2016 - Lab 11A

Quick Links: Blackboard | EECS | Mines | Piazza | zyBooks

|   Home |  Contact |  Syllabus |  Assignments |  Schedule |  Resources   |
This lab is due by November 18, 2016 08:00am.


Concepts



Focus on defining a Date 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 Visual Studio. Doing this will help you see where you might make mistakes on the exam!

You should write a main.cpp that tests each feature of your class works as expected. You will need to submit your class prototype file, your class implementation file, and your main.cpp file for this lab with Assignment 11.


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 know why private makes sense; ask it 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, year can't be negative, etc.) and, if not, resets the date object to the default values. This function should be called by all functions that modify the date object.
  • A boolean member function that returns whether the callee is earlier than the date argument passed.
Extra credit point 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.


Lab Submission



You will submit your solution to this lab with the rest of Week11. Detailed instructions for doing this are posted in Assignment 11.


This lab is due by November 18, 2016 08:00am.
Last Updated: 01/01/70 00:00


Valid HTML 4.01 Strict Valid CSS! Level Triple-A conformance, W3C WAI Web Content Accessibility Guidelines 2.0