Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Form the subclass Manager from the class Employee. A Manager has a bonus. Supply a constructor to the Manager class that takes id, salary and

Form the subclass Manager from the class Employee. A Manager has a bonus.

Supply a constructor to the Manager class that takes id, salary and bonus of a Manager. The constructor initializes all the instance variables of a Manager object.

The toString method of Manager should yield a string such as

id = 222 salary = 15.0 bonus = 5.0 
public class Manager { private double bonus; } public class Employee { private int id; private double salary; public Employee (int theID, double theSalary) { id = theID; salary = theSalary; } public String toString() { return "id = " + id + " salary = " + salary; } } 

Here is a tester.

 public class EmployeeTester { public static void main(String [] args) { Employee e1 = new Employee(111, 10.0); Employee e2 = new Manager (222, 15.0, 5.0); System.out.println(e1.toString()); //prints id = 111 salary = 10.0 System.out.println(e2.toString()); //prints id = 222 salary = 15.0 bonus = 5.0 } }

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_2

Step: 3

blur-text-image_3

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

=+What kinds of problems need to be overcome?

Answered: 1 week ago

Question

=+Describe an important trade-off you recently faced

Answered: 1 week ago