Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Project goals: This project assignment will provide some experience with multiple inheritance. You will be required to create Java source files. Be sure to

Java Project goals: This project assignment will provide some experience with multiple inheritance. You will be required to create Java source files. Be sure to submit the source codes together with the execution of them.

Function Requirements: You are to create the following classes with the specified methods. These classes are created with the specified Person super class. After creation you should test these classes with the main program. The methods required for this assignment are as follows:

Methods for class Employee: set/getSalary toString

Methods for class Stockholder: set/get baseSalary set/get NumberOfShares set/getDividendsPerShare ComputeDividends toString

Methods for class Executive: basePlusDividendSalary toString The Executive class is publically derived from Stockholder. The Employee and Stockholder classes use a Person class. Then modify the Executive class as necessary.

The methods for the classes listed above can be implemented in the class or inherited from some super classes. If input values are invalid, throw exception such as an IllregalArgumentException. For example, if (grossSales < 0.0) throw new IllegalArgumentException(Gross Sales should be greater than 0.0.); this.grossSales = grossSales;

Sample Test Code // assign superclass reference to superclass variable

Stockholder sObj = new Stockholder("David NewMan", "4607 Westerdale Dr", 80000, 50,10);

//assign subclass reference to subclass variable Executive exObj = new Executive("John Smith","444 William Ave",130000,100, 10);

// invoke toString on superclass objet using superclass variable System.out.printf(.., sObj.toString());

//invoke toString on subclass object using subclass variable System.out.printf( .., exObj.toString());

//invoke toString on subclass object using superclass variable Stockholder sObj2 = exObj; System.out.printf(.., sObj2.toString());

Sample Output run:

Polymorphism Test:

Assigning superclass and subclass reference to superclass and subclass variables.

Call Stockhoder's toString with superclass variable to superclass object

Name: David NewMan

Address: 4607 Westerdale Dr

Base Salary: $80,000.00

Number of Shares: 50

Dividend per Share: $10.0

Total Dividend: $500.00

Call Executive's toString with subclass variable to subclass object

Name: John Smith

Address: 444 William Ave

Base Salary: $130,000.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions