Repeat Programming Project 2 in Chapter 5. This time, add the following four constructor methods: one for each instance variable, one with two parameters for the two instance variables, and a default constructor. Be sure that each constructor sets all of the instance variables. Write a driver program to test each of the methods, including each of the four constructors and at least one true and one false case for each of the test methods.

The solution to this project sets the name parameter to “No name” and age to 0 if they are not specified in the constructor. In addition, if the age argument is a negative number an error message is printed and the age is set to 0.

See the code in PersonCh6.java and PersonCh6Test.java.

Computer Science & Information Technology

You might also like to view...

A chart is specific to a graph that displays a relationship between two sets of numbers plotted as data points with coordinates on a grid

Indicate whether the statement is true or false

Computer Science & Information Technology

Use the expression ________ to obtain the ith element through the jth element of list sequence, inclusive.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology