inheritance and polymorphism, Other Engineering

Assignment Help:
The objective of this programming assignment is to experience the use of inheritance in Java and to see how polymorphism works with inheritance in Java.
The assignment involves writing three classes, plus a test class. The base class is a TaxableWorker class which contains a couple of attributes and methods common to all workers. The first derived class is a StateTaxableWorker which adds state tax information to a TaxableWorker. The second derived class is a LocalTaxableWorker which adds local tax information to a StateTaxableWorker. The test program will be structured to include a method which accepts a base class reference and demonstrates polymorphic behavior.
NOTE: None of the first three classes below do any user input or console output! User input and console output are only done in the test program!
The details of the three classes to be implemented are as follows:
1. A TaxableWorker contains a name, an hourly pay rate (ie. 12.50/hr), and a federal tax rate (ie. 0.25). An explicit value constructor must be provided to set all three values. There must be mutator methods to change the values of the pay rate and the tax rate. There must be ONE workerInfo method that returns a string containing the name, hourly pay rate, and federal tax rate. There must be a grossPay method that takes the number of hours worked as a parameter and calculates the gross pay (hours * payRate) and returns that as a double. There must be a taxWithheld method that takes a gross pay amount as a parameter and calculates the tax withheld (grossPay * taxRate) and returns that as a double.

2. The StateTaxableWorker class inherits from the TaxableWorker class. This class adds attributes for the state name and the state tax rate (ie. 0.05). An explicit value constructor must be provided to set the three values of the base class plus the values for the state name and state tax rate. A mutator method must be provided to change the value of the state tax rate. The base class workerInfo method must be overridden to include all the base class worker information plus the state name and state tax rate information. The base class taxWithheld method must be overridden to include the base class tax withheld plus the state tax withheld (gross pay * state tax rate).

3. The LocalTaxableWorker class inherits from the StateTaxableWorker class. This class adds attributes for the city name and the city tax rate (ie. 0.025). An explicit value constructor must be provided to set the three values of the base class plus the two values for the state name and state tax rate plus the city name and the city tax rate. A mutator method must be provided to change the value of the city tax rate. The base class workerInfo method must be overridden to include all the state worker information (which includes base class info) plus the city name and city tax rate information. The base class taxWithheld method must be overridden to include the state tax withheld (which includes the base tax withheld) plus the city tax withheld (gross pay * city tax rate).

4. The test program needs to create a StateTaxableWorker object and a LocalTaxableWorker object. The test program must contain a display method which takes a base class TaxableWorker object reference along with the number of hours worked by the worker. The display method should use the base class workerInfo method to get the name and tax information about the worker and output that information. The display method should also use the base class grossPay method to get the pay info for the worker and display that information. Then the display method should use the taxWithheld method to output the total amount of tax withheld for the worker.

The test program should pass the StateTaxableWorker object and the LocalTaxableWorker object to the display method along with the number of hours each worker has worked. The output seen should demonstrate polymorphic behavior, that is the base class TaxableWorker reference to a StateTaxableWorker object elicits StateTaxableWorker tax information and correct tax withheld, and the base class TaxableWorker reference to a LocalTaxableWorker object elicits LocalTaxableWorker tax information and correct tax withheld.

Related Discussions:- inheritance and polymorphism

Tool life, hi I''m doing research in tool life of solid carbide endmills ...

hi I''m doing research in tool life of solid carbide endmills and I was looking at your formulas. I was wondering if tell me or where I can find the data required for these formu

Pn junction diode, what is the effect of temperature on pn junction diode o...

what is the effect of temperature on pn junction diode of component

Programming, A charitable organization wants to design a special ATM machin...

A charitable organization wants to design a special ATM machine to be used by needy people. The association supplies the needy person with a pin number to be able to use the ATM

#title.project, what type of projects are take place in the chemical engin...

what type of projects are take place in the chemical engineering

Re-heat ignition system in aircraft engine, Re-heat Ignition The atomis...

Re-heat Ignition The atomised fuel spray is fed into the re-heat jet pipe and ignited by one of three methods:- • Spark Ignition • Hot Streak Ignition • Catalytic Ignition a

Finance Project, You are interested in proposing a new venture to the manag...

You are interested in proposing a new venture to the management of your company. Pertinent financial information is given below. BALANCE SHEET Cash 2,000,000 Accounts Payable and

MIMO, I need some help

I need some help

Iosipescu shear test, A second way to determine the shear modulus is to use...

A second way to determine the shear modulus is to use the Isopescu shear test. The sample is placed in a jig and loaded as shown. Under load, a region of pure shear exists

Human Motion Kinetics, Beginning from rest when theta=10 degrees, a 30-kg c...

Beginning from rest when theta=10 degrees, a 30-kg child slides without kinetic friction down the slide which is in the shape of a 2.5 meter circular arc. Determine the child''s sp

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd