![]() |
Help: Equality in Java
Help is available for each task, or you can go straight to the solution source code.
Use a for loop to loop through the employee array. Compare each Employee to the given one using ==. Return the given Employee if the test is true. Return false after the loop is done, indicating that no match was found. Task 2Add a similar method called findEmployeeNamed. This method takes as its argument a String name and tries to find an Employee of that name. It returns the Employee object if successful.Use a loop similar to the one above, but use the equals method to compare the names of the Employees to the given name. Task 3Add code in the main method of the EqualityTest class to use these two new methods to search for some employees.Add a call to findEmployee using a known Employee of the Company. Also add a call to findEmployeeNamed with the name of a known Employee. You can also add seaches that will fail. Task 4Run your solution via the EqualityTest class. |
Copyright © 1996-1997 MageLang Institute. All Rights Reserved. |