CS 1063  Lab 4:  Using and Modifying a Class

The BirthdaySong Class

Objectives

Hand-in Requirements

All projects and laboratories will be submitted electronically through webCT.  Zip up your entire project directory to submit as the source.  (Right click on the project folder and follow the SentTo link.)  The project directory should include the following:

Details

You will modify a class named BirthdaySong.  This class has a method named sing that prints the words for Happy Birthday.  However this song does not mention the name of the birthday person.  We would like it to sing to a person that the client designates.  Your job will be to test and modify this class.


public class BirthdaySong {  
  // Constructor
  public BirthdaySong() {  

  }

  public void sing() {
      System.out.println("Happy birthday to you");  
      System.out.println("Happy birthday to you");
      System.out.println("Happy birthday dear ");
      System.out.println("Happy birthday to you");
  }
}

Part 1:  Write the public interface for the BirthdaySong class and be sure to add comments to each method

Part 2:  Setup:

Part 3:  Modify and Test:

  1. Test the BirthdaySong class.

    After you have checked to see if your output is correct, comment out the above two lines using /*  and */
  2. Modify the BirthdaySong class so that it sings the song to a person whose name is supplied by the client.

  3. Test your modifications.