Overview

In this reading we’ll round out our knowledge of class design by learning about main methods and how to write them and learning how to create documentation using Javadoc comments. You’ll also see the design of another class, ClassPeriod, that makes use of another class that was already explored, the Student class.

Required Reading

Sections 11.6-11.8 (pp. 366-373) from the course textbook.

Learning Objectives

BASIC Learning Objectives

Each student will be responsible for learning and demonstrating proficiency in the following objectives PRIOR to the class meeting. The reading quiz will test these objectives.

  1. Describe the role of the main method.
  2. Provide a rationale for each part of the method header for the main method (e.g. visibility, return type, …).
  3. Describe the meaning of each of the Javadoc comment tags (e.g. “@author” and “@param”).
  4. Write Javadoc comments for classes, methods, and constructors.

ADVANCED Learning Objectives

The following objectives should be mastered by each student DURING and FOLLOWING the class session through active work and practice.

  1. Write a class that includes a main method to create objects of that class and invoke methods on them.
  2. Write a class that has fields whose type is that of another class you have written.

Pre-class Exercises

These exercises are geared towards mastering the BASIC learning objectives listed above. You are expected to submit them before class and it is highly recommended that you complete them before attempting the reading quiz.

  1. Write a Java class named HelloWorld. This class contains only one thing: a main method that prints out the string “Hello World.”

  2. Write a Java class named StudentClub. This class should contain 3 fields: the name of the club (a String), the members of the club (an array of Student objects), and the president of the club (a single Student object) This class should also contain a method named printMembers which should print out the name of every member in the club. You may assume that the Student class has a method named getName that can be used to retrieve the name of the student.

    Your code should contain Javadoc comments for the class and method.