LAB 12B - COMPOSITION PRACTICE

Concepts

Define a more complex class by using a previously written class. You will need to submit your solution to this lab with Homework 12.

Suggestion (again): 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!

MyDate: Composition time!

We've heard that dating is a major activity here at Mines (right?); thus, many folks may be overwhelmed with keeping track of their dating history. What was that person's name? How old is he/she? What did I think of the date?

Your goal is to first write a new class that allows the user of your class to keep track of some basic information about each date you have had. For example, once your new class exists, you might have two MyDate objects that store the Date of a date, the date's name, the date's age, and your rating for the date:

11/1/2015
Pat
23
5

11/10/2015
Unknown
21
2

What data types should you use to represent these four aspects of a date? Hopefully you are thinking the date (mm/dd/yyy) of your outing should be represented with a Date object (not a string), via your Date class from Lab12A! For simplicity, you can assume the user of your MyDate class only wants to store a date's first name.

Include appropriate constructors, as well as mutator and accessor functions. Also ensure that your class verifies a date's age is always over 18 (else that's illegal!) and that the rating value assigned is between 1 and 5.

MyDate Use

For the class use piece, create an array (or vector) of 10 MyDate objects (or more if you typically have more than 10 dates per week ... wowzer!). Then, in main.cpp, read in a file that lists all your dates from last week. You can use this file for testing purposes (or create your own).

Once all dates are read into your MyDate objects, then loop through the dates stored and print all those that received a 5 rating. To print each date with the highest rating, create a PrintMyDate function that returns nothing and takes one MyDate object as its parameter.

For the provided input file, the output of your program should be:

Date: 2/1/2015
Name: Pat
Age: 23
Rating: 5

Date: 3/12/2015
Name: Taylor
Age: 20
Rating: 5