lab5 - CS116 LAB 5 BRING THIS COPY WITH YOU ON MARCH 15 It...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
CS116 LAB 5 BRING THIS COPY WITH YOU ON MARCH 15 It it is due on Wednesday June 30 on Blackboard by 10:00 p.m time stamped. Use EditPlus to create source code. Objectives: 1. Inheritance. 2. Abstract classes. 3. Polymorphism. 4. Interfaces and multiple inheritance. Task 1 (0.4 points) This lab is a continuation of the exercisePreLab5.doc document given in class on March 1. As part of that exercise you should had created: An abstract class called Employee. This class has an abstract method called compensation. A class called Engineer which inherits Employee and implements the code for the abstract method compensation, as applied to an engineer’s salary. 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
A class called Management which inherits Employee and implements the code for the abstract method compensation, as applied to a manager’s salary. A class called AdministrativeParsonnel which inherits Employee and implements the code for the abstract method compensation, as applied to an administrative personnel’s salary. Include the source code and compiled files for the above classes under Task1. Now answer the questions below before we proceed with additional code: 1. Can we instantiate an object of an abstract class in another class? ______________ 2. What happens to a class that inherits an abstract class but it does not implement the abstract method of the super class? 3. Can interfaces extend another class? _____________ 4. Can an interface have instance variables besides abstract methods, and if it can what are the restrictions?______ 2
Background image of page 2
5. Can a class that implements an interface implement 1 of 3 methods defined in that particular interface or does it have to implement all 3? _________ 6. How can we implement multiple inheritance in Java (just a one sentence statement like: through the usage of ….)? ___________________ 7. Does the concept of polymorphism apply in the Employee , Engineer, Management, AdministrativePersonnel classes that we created and why?____________________________________ 8. In using super in the constructor of Engineer class what method are we calling? ________________________________________________ Task 2 (0.8 points) 1. Create a class called Payroll. This class has the methods describe below and acts as a client to the hierarchical tree of Employees created as part of the exercisePreLab5. No packaging is needed. Notice that there is no 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
inheritance here. Class Payroll “uses” classes Engineer, AdministativePersonnel, Management and their superclass Employee. 2. Create a method called listOfEmployees. This method takes no arguments and returns an ArrayList of Employee type. This method creates objects of each type of the 3 employees we have (Engineer, AdministrativePersonnel, Management) by reading the data from the file employee.txt . The file is given as part of this lab. There is one line of data for each employee in the text file. The tokens are separated by comas. Your code should recognize the type of employee from the first String in a
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 15

lab5 - CS116 LAB 5 BRING THIS COPY WITH YOU ON MARCH 15 It...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online