![]() |
Help: Reference Semantics in Java
Help is available for each task, or you can go straight to the solution source code.
Remember, to add a method to the Employee class you need to open a Class Browser by selecting the Workspace->Open Class/Interface Browser... menu-item from the Workspace or Scrapbook windows. When asked to Select a class, simply type in Employee. Before setting up the new relation, it must break any existing
relationships: If the new Project already has an owner, it must set
the owner's Project to null. In a similar fashion, if the
Employee already has a Project, the Project's
owner must be set to null.
Since the project may be null, test for this before printing it out, then print either "null" or the name of the project. Task 3Augment the toString method of Project to print out its current owner.Use the conditional operator ?: here as well. Print out the name of the owner if there is one. Task 4Run the program via the RefTest class, and note the output that appears in the Console window.In the Workspace window, click on the RefTest package in the Magelang/JavaBasics package and then select the Selected->Run->Run main... menu-item and click the Run button when the dialog appears. |
Copyright © 1996-1997 MageLang Institute. All Rights Reserved. |