go to previous page   go to home page   go to next page

Answer:

The missing parts have been filled in, below.


Valentine Card

Here is the complete birthday card:

class Birthday extends Card 
{
  private int age;

  public Birthday ( String r, int years )
  {
    recipient = r;
    age = years;
  }

  public void greeting()
  {
    System.out.println("Dear " + recipient + ",\n");
    System.out.println("Happy " + age + "th Birthday\n\n");
  }
}

The Valentine class is much the same, except for some added passion:

class Valentine extends Card 
{
  private int kisses;

  public Valentine ( String r, int k )
  {
    recipient = r;
    kisses    = k;
  }

  public void greeting()
  {
    System.out.println("Dear " + recipient + ",");
    System.out.println("Love and Kisses,");
    for ( int j=0; j<kisses; j++ )
      System.out.print("X");
    System.out.println("\n");
  }
}

QUESTION 11:

Each greeting() method from each of the sibling classes is different. Do they all meet the requirement of the abstract parent class, Card?


go to previous page   go to home page   go to next page