Dear Valerie, Happy 7th Birthday How you have grown!!
Assume that AdultBirthday
has been defined.
It will look much like YouthBirthday
but with a
slightly different
birthday message.
Here is a program fragment (part of main()
in another class):
AdultBirthday ab = new AdultBirthday( "Walter", 47 ); ab.greeting();
It will write out:
Dear Walter, Happy 47th Birthday You haven't changed at all!
Now inspect the following code:
Card crd = new YouthBirthday( "Valerie", 7 ); crd.greeting(); crd = new AdultBirthday( "Walter", 47 ); crd.greeting(); crd = new Birthday( "Zoe", 30 ); crd.greeting();
Is this code correct? Can crd
be used for
each of the three objects?