Question
JAVA Below is source code to define a Person class. Examine the source code and answer the questions below: public abstract class Person { private
JAVA
Below is source code to define a Person class. Examine the source code and answer the questions
below:
public abstract class Person {
private String name;
private String gender;
private String address;
public Person(String name, String gender, String address){
this.name = name;
this.gender = gender;
this.address = address;
}
public String getName() {
return name;
}
public String getGender() {
return gender;
}
public String getAddress() {
return address;
}
public abstract void displayDetails();
}
Write source codes in the Java programming language to define Customer and Salesperson classes that inherits from the Person class defined in the above source code. The Customer class should have an additional attribute called amountSpent of double data type. The Salesperson class should have an additional method called calculateDiscount that takes customer object as an argument, calculates a 10% discount and returns double type. The displayDetails method of the Customer class should display a message which is different from that of the Salesperson class.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started