CSCI 261 - Programming Concepts (C++)Spring 2017 - Lab 11BQuick Links: Blackboard | Canvas | CS @ Mines | Cloud9 | Piazza | zyBooks |
|
| Home | Contact | Syllabus | Assignments | Schedule | Resources | | |
This lab is due by
April 18, 2017 11:59pm.
ConceptsDefine a more complex class by using a
previously written class. You will need to submit your solution to this
lab with Assignment 11.
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 Lab11A! 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 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
April 18, 2017 11:59pm.
| |
Last Updated: 01/01/70 00:00
|