![]() |
Help: Using Interfaces in Java
Help is available for each task, or you can go straight to the solution source code.
The getName method in NamedInterface has the same signature as the getName method in the NamedEntity class. Task 2Modify the abstract class NamedEntity so that it implements NamedInterface.Add the necessary implements clause to the class declaration of NamedEntity. Task 3Create the Client interface. It extends the NamedInterface with two new methods, contractAmount and contractDescription. The first method has no arguments and returns an int. The second also has no arguments but returns a String.Task 4Modify the Person class to implement the Client interface. The contractAmount method should return a constant value of 100. The contractDescription method should return a String with the name of the person and the amount of the contract.The contractAmount method simply returns 100. The contractDescription method should return a readable String, such as "Client bob is contracted for 100 dinars". Task 5Modify the Company class to implement the Client interface in the same way, but this time return 200 for the value of the contract.Add the methods to the Company class as described in the task above. |
Copyright © 1996-1997 MageLang Institute. All Rights Reserved. |