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 
{
  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 
{
  int kisses;

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

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

QUESTION 8:

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