The revised class is seen below.
Now objects of the YouthBirthday
class have two methods:
greeting()
,
and greeting( String )
// Revised version // class YouthBirthday extends Birthday { public YouthBirthday ( String r, int years ) { super ( r, years ) } // additional method---does not override parent's method public void greeting( String sender ) { super.greeting(); System.out.println("How you have grown!!\n"); System.out.println("Love, " + sender +"\n" ); } }
Here is a YouthBirthday
object using each of its two methods:
YouthBirthday yBday = new YouthBirthday( "Henry", 12 ); yBday.greeting(); yBday.greeting( "Alice" );