![]() |
Some Methods
PrerequisitesThis Magercise extends the previous one by introducing a Company class. This new class maintains a collection of Employees using an array for storage. Many JDK classes use arrays in this manner.Using an array is perhaps not the easiest way to do this, but it does have the advanage of being typed, unlike the use of Vectors or Hashtables, which will be explored in later Magercises. A skeleton of the Company class is given. Two methods have to be implemented to complete the needed functionality, addEmployee and toString. This magercise also makes use of Strings. Methods are discussed in detail in the course notes. Work LocationPerform all work for this magercise in VisualAge project MageLang Magercises, package magercises.moreclasses. If this project does not appear in your Workspace add it from the repository (if it exists there) or create a new project using this name. Tasks
Perform the following tasks:
Write the addEmployee method of Company. It will add an Employee into the array. Be sure that it can handle cases where the array is full. Implement a toString method for Company. It should return a String containing the name of the company, then iterate through the array of employees, printing each.
|
Copyright © 1996-1997 MageLang Institute. All Rights Reserved. |