Problem 8
(Quadritateral Inberitance Hierarchy) Write an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square. Use Quadrilateral as the superclass of the hierarchy. Create and use a Point class to represent the points in each shape. Make the hierarchy as deep (i.e., as many levels) as possible. Specify the instance variables and methods for each class. The private instance variables of Quadrilateral should be the \(x-y\) coordinate pairs for the four endpoints of the Quadrilateral. Write a program that instantiates objects of your classes and outputs each object's area (except Quadrilateral).
Problem 9
(What Does Each Code Snippet Do?) a) Assume that the following method call is located in an overridden earnings method in a subclass: super .earnings() b) Assume that the following line of code appears before a method declaration: QOverride c) Assume that the following line of code appears as the first statement in a constructor's body: super(firstArgument, secondArgument);
Problem 14
$(Employee Hierarchy) In this chapter, you studied an inheritance hierarchy in which class BaseP 7 us CommissionEmployee inherited from class CommissionEmployee. However, not all types of employees are CommissionEmployees. In this exercise, you'll create a more general Employee superclass. that factors out the attributes and behaviors in class CommissionEmployee that are common to all Employees. The common attributes and behaviors for all Employees are firstName, lastName, socialsecurityNumber, getFirstName, getLastName, getSocial SecurityNumber and a portion of method toString. Create a new superclass Employee that contains these instance variables and methods and a constructor. Next, rewrite class CommissionEmployee from Section 9.4 .5 as a subclass of Employee. Class CommissionEmployee should contain only the instance variables and methods that are not declared in superclass Employee. Class CommissionEmployee's constructor should invoke class Employee's constructor and CommissionEmployee's toString method should invoke Employee's toString method. Once you've completed these modifications, run the CommissionEmployeeTest and BasePlusCommissionEmployeeTest apps using these new classes to ensure that the apps still display the same results for a CommissionEmployee object and BaseP 7 usCommissionEmployee object, respectively.