Reference no: EM133108971
COIT20256 Data Structures and Algorithms - Central Queensland University
Assessment: Implement the classes created in Activities One and Two and submit your source code (.java) files.
Tutorial Questions
Question 1: What are abstract methods? Describe the circumstances in which an abstract method would be appropriate.
Question 2: Compare and contrast abstract classes and interfaces. Why would you use an abstract class? Why would you use an interface?
Question 3: Distinguish between an abstract class and a concrete class.
Question 4: (Payroll System Modification) Modify the payroll system of Figs. 10.4-10.9 of textbook to include an additional Employee subclass PieceWorker that represents an employee whose pay is based on the number of pieces of merchandise produced. Class PieceWorker should contain private instance variables wage (to store the employee's wage per piece) and pieces (to store the number of pieces produced). Provide a concrete implementation of method earnings in class PieceWorker that calculates the employee's earnings by multiplying the number of pieces produced by the wage per piece. Create an array of Employee variables to store references to objects of each concrete class in the new Employee hierarchy. For each Employee, display its string representation and earnings.
Question 5: (Accounts Payable System Modification) In this exercise, we modify the accounts payable application of Figs. 10.11-10.15 to include the complete functionality of the payroll application. The application should still process two Invoice objects, but now should process one object of each of the four Employee subclasses (Figs. 10.5- 10.8). If the object currently being processed is a BasePlusCommissionEmployee, the application should increase the BasePlusCommissionEmployee's base salary by 10%. Finally, the application should output the payment amount for each object. Complete the following steps to create the new application:
a) Modify classes HourlyEmployee and CommissionEmployee to place them in the Payable hierarchy as subclasses of the version of Employee that implements Payable (Fig. 10.13). [Hint: Change the name of method earnings to getPaymentAmount in each subclass so that the class satisfies its inherited contract with interface Payable.]
Attachment:- Data Structures and Algorithms.rar