Customer Service Chat
Get quote & make Payment
inheritance and polymorphism, Other Engineering
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.
Posted Date: 3/15/2013 3:13:19 PM | Location : United States
Ask an Expert
inheritance and polymorphism, Assignment Help, Ask Question on inheritance and polymorphism, Get Answer, Expert's Help, inheritance and polymorphism Discussions
Write discussion on inheritance and polymorphism
Your posts are moderated
Write your message here..
Router, how does the Ip message finally reassemble?
how does the Ip message finally reassemble?
Assignment on risk and return, Assignment on Risk and Return# Stock has bet...
Assignment on Risk and Return# Stock has beta of 1.5 & an expected return 11%. A risk free asset earns 2%. Determine the expected return on a portfolio that is equally invested in
Tcp/ip, Discuss the effect of supernetting on routing and explain how the i...
Discuss the effect of supernetting on routing and explain how the issue has been tackled. Effect: increased routing information
Manual override relays, Manual override relays: When the manual-overrid...
Manual override relays: When the manual-override relays are not energised, this current flows through brushes riding on slip rings mounted on the propeller spinner bulkhead and
Time value of money-inflation-interest rate-opportunity cost, Time Value of...
Time Value of Money Consider your cheese steak hoagie business. Assume that Phillies will win another World Series, and your business will be hired to serve a party that will
Lamination of plastics, Q. Write short note on laminating. ...
Q. Write short note on laminating. OR Explain the Laminating processes.
Internal rate of return irr, Internal rate of return IRR In case of IRR met...
Internal rate of return IRR In case of IRR method cash flow are analyzed taking into account the magnitude and the timing. IRR is that discount rate which gives a net present value
Vertical spread, what are the no-arbitrage lower bound of the vertical spre...
what are the no-arbitrage lower bound of the vertical spread
Engine speed indicators, Engine speed indicators: All engines have thei...
Engine speed indicators: All engines have their rotational speed (R.P.M.) indicated. On a twin or triple-spool engine, the high pressure assembly speed is always indicated; in
Trigonometry( bearings and rectilinear figures), a pilot entering a bay on ...
a pilot entering a bay on course 60.3 degrees at speed 12 miles per hour sees a light bearing 37.3 true and 20 minutes later he sees it bearing 20.0 degrees true. if he keeps the
Accounting Assignment Help
Economics Assignment Help
Finance Assignment Help
Statistics Assignment Help
Physics Assignment Help
Chemistry Assignment Help
Math Assignment Help
Biology Assignment Help
English Assignment Help
Management Assignment Help
Engineering Assignment Help
Programming Assignment Help
Computer Science Assignment Help
Why Us ?
~24x7 hrs Support
~Quality of Work
~Time on Delivery
~Privacy of Work
Human Resource Management
Literature Review Writing Help
Terms & Conditions
Copyright by ExpertsMind IT Educational Pvt. Ltd.