CS1027b Computer Science Fundamentals II

Lab 2

General lab instructions to help labs run smoothly

Overview and preparation

Inthis lab you will work with your own classes, and Javadoc. Upon completion of this lab, you should be able to do the following:

Make sure you show the result(s) of each Exercise to your TA, to get your marks for the lab. Please submit the .java files your wrote on owl.

Preparation: make sure you understand the parts of a class definition: instance variable declaration, constructor definition, method definition. Read this introduction to Javadoc.

Exercise 1: Adding a Test Harness to the Person class

To make it easier to test code that you have written for a Java class you can add to that class a main method that acts as a "test harness". A test harness is a main method that includes calls to methods that you wish to test. For convention this main method is the last method of the class.

If you have a test harness, you do not need to have a separate application program in order to test your class: the test harness is part of the class you are testing. In this part of the Lab, you will get some experience in writing a test harness.

Make sure you show your results to the TA.

Exercise 2: Adding to the SocialNetwork Class

Make sure you show your results to the TA.

Exercise 3: Using Javadoc comments

Make sure you show your results to the TA.

Exercise 4: Using the SocialNetwork Class in an Application

Make sure you show your results to the TA, and submit on owl.