SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Stuart Reges, Marty Stepp
Chapter:
Inheritance And Interfaces
Exercise:
Exercises
Question:1 | ISBN:9780136091813 | Edition: 2

Question

Write the class Marketer to accompany the other law firm classes described in this chapter. Marketers make $50,000 ($10,000 more than general employees) and have an additional method called advertise that prints "Act now, while supplies last!" Make sure to interact with the superclass as appropriate.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

// package classes;

public class Marketerer extends Employee {

    // this method return the salary with 10000 more than general employee
	public double getSalary() {

        // get the super class salary and adds another 10000
		double marketerSalary = super.getSalary() + 10000.0;
		return marketerSalary;

	}

    // newly added advertise method
	public void advertise() {
		System.out.println("Act now, while supplies last!");
	}

	public static void main(String args[]) {

	}

}

// package classes;

public class Employee {

	public double getSalary() {
		
		double salary = 40000;
		return salary;
	}

}

 

0 0

Discussions

Post the discussion to improve the above solution.