Valentine Card

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

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?