| CS 311 Fall 2009 > Assignment 1 |
Assignment 1 is due at 5 p.m. Thursday, September 17. It is worth 25 points.
This assignment is to be done individually.
E-mail
answers to the exercises below to
ffggc@uaf.edu,
using the subject
“DA1”.
birthday.h and birthday.cpp, from Exercise A.
The two files (or a single archive file containing them)
should be attached to your e-mail message.In this exercise, you will write a simple class of the sort that might have been done as an exercise in operator overloading in CS 202. However, a number of the concepts covered so far in CS 311 will need to be applied, including documentation comments based on the idea of an operation contract. Further, your code will need to work with a thorough test program. Most importantly, quality standards will be quite high.
This assignment is to be done individually.
Implement a C++ class that holds information about a someone’s birthday: their name, and the date of the birthday. Be sure to follow the coding standards. You do not need to follow the standards in part 3 (“Additional Standards”); these come later.
Birthday”, and implement it
in files birthday.h and birthday.cpp.Birthday should act as if it maintains three data items:
"")
and the date to January 1.getName and getMonth, and getDay.setName, setMonth, and setDay.toString.
This should take no parameters and return a string representation of the stored information:
the name, followed by a blank and a left parenthesis (“(”), the month, as a 3-letter abbreviation (“Jan”, “Feb”, etc.), a blank, the day, as an integer, and a right parenthesis (“)”).
Fred Q. Smurd”, the month is 3, and the day is 5,
then toString should return “Fred Q. Smurd (Mar 5)”.==”) and inequality (“!=”)
operators for comparing two Birthday objects.
They are equal if the names, months, and days are all equal.<<”) operator.
This should output to the given stream the same string as that generated by toString.std::string,
and all integers should be handled using type int.
I have written a test program:
birthday_test.cpp.
If you compile and run your package with this program (unmodified!), then it will test
whether your package works properly.
Do not turn in birthday_test.cpp.
Note: The test program does not check the following, but you still need to do them correctly.
| CS 311 Fall 2009: Assignment 1 / Updated: 11 Sep 2009 / Glenn G. Chappell / ffggc@uaf.edu |
|