$20.00 Program composition
- From Computer-Science: Object-Oriented-Programming
- Closed, but you can still post tutorials
- Due on May. 24, 2012
- Asked on May 21, 2012 at 11:05:31PM
Write a Date Class to add to the program you wrote last week (The Student Class
Program) One basic rule of OO programming is not to save anything that can be calculated.
The date class will allow you to calculate the student’s age.
A date class
o Attributes
§ Day
§ Month
§ Year
o Behaviors
§ Set and
get each attribute
§ Calculates age in a behavior
called calcage( ) that determines a person’s age as of today
Validate
each attribute – as part of the set method call the validate methods
Day
1 to the number of days in the month
Don’t forget leap year. Leap year is more than every 4th year is a leap year – look it
up
Month
Accept 3-letter abbreviations; Jan, Feb, Mar, . . .
Make the input case insensitive. Also accept integers, 1 – 12
Year
Is 99 a valid year? Is 10 a valid year?
If 99 means 1999 does 10 mean 1910?
Define a year format and enforce it.
Add birth date as an attribute to your Student – an abstract variable (one created
from an abstract data type) that is an attribute of another abstract data type
(such as your Student Class) illustrates Composition.
Add methods to your StudentManip class to input (set) the student’s birth date and
to calculate the student’s age. Add the student’s age to the display classes.
- This tutorial hasn't been purchased yet.
- Posted on May. 22, 2012 at 12:18:38AM

Attachments:
assignment.xlsx (11K)