In the following there are two classes, Employee and Manager. Manager is a subclass of Employee. The implementation of Employee class is given (Note: no getter methods are provided, so you are not able to access instance variables through getter methods in the subclass). The skeleton of the Manager class definition is given. Complete the constructor method, and the toString method for the subclass (see the details below). public class Employee { private String name; private double salary; // Make an employee with a given name and salary. public Employee(String aName, double aSalary) { name = aName; salary = aSalary; } // Provide a string description of an employee. public String toString() { return "Name: " + name + "\tSalary: " + salary; } } public class Manager extends Employee { private String department; // Make a manager with a given name, salary, and department. public Manager(String name, double salary, String department) { // put your code below } // Provide a string description of a manager. public String toString() { // put your code below } }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question
100%

In the following there are two classes, Employee and Manager. Manager is a subclass of Employee. The implementation of Employee class is given (Note: no getter methods are provided, so you are not able to access instance variables through getter methods in the subclass). The skeleton of the Manager class definition is given. Complete the constructor method, and the toString method for the subclass (see the details below).

public class Employee {

private String name;

private double salary;

// Make an employee with a given name and salary.

public Employee(String aName, double aSalary) {

name = aName;

salary = aSalary;

}

// Provide a string description of an employee.

public String toString() {

return "Name: " + name + "\tSalary: " + salary;

}

}

public class Manager extends Employee {

private String department;

// Make a manager with a given name, salary, and department.

public Manager(String name, double salary, String department)

{ // put your code below

}

// Provide a string description of a manager.

public String toString()

{ // put your code below

}

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT