Help: Working With Class Information


Help is available for each task, or you can go straight to the solution source code.

Task 1

Implement the totalIndividualContracts method of the Company class. The signature of this method is given in the starter file.
The bulk of the code in this new method is the same as the code in the Company method contractListing. But instead of iterating through the Clients and printing them to a buffer, check each to see if it is an instance of class Person, and if so, add it to a running total. To check if an instance is of the class Person, use the methods getClass and getName to get the name of a class from an Object. Then use String.equals to compare it with the string "Person".

Copyright © 1996-1997 MageLang Institute. All Rights Reserved.