Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I just need help on doing some inheritance for my JAVA project I have the codes I did from before. it's asking me to

Hello I just need help on doing some inheritance for my JAVA project I have the codes I did from before. it's asking me to Design a base insurance policy class, named Policy,and this is to be the parent class for any type of insurance policy. it is also asking me to Re-design the Auto, Home, and Life insurance policy classes from the previous lab as deriv//ed classes fro/m this new ba/se Policy class. Lastly it's asking me to use my existing CommissionCalculator and driver classes. Note you do not need to modify these classes. The lab should execute exactly the same as the previous lab.

///////AUTO POLICY/////

public class Auto {

private String name; private String make; private String model; private double liability; private double collision;

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getMake() { return make; }

public void setMake(String make) { this.make = make;

}

public String getModel() {

return model;

}

public void setModel(String model) {

this.model = model;

}

public double getLiability() {

return liability;

}

public void setLiability(double liability) {

this.liability = liability;

}

public double getCollision() {

return collision;

}

public void setCollision(double collision) {

this.collision = collision;

}

public Auto(String firstName, String lastName, String make, String model, double liability, double collision, String name) { this.name = name; this.make = make; this.model = model; this.liability = liability; this.collision = collision;

}

public String toString() {

return "Auto:"+" Name = " + name + ", Make = " + make + ", Model = " + model+ "," + " Liability = " + liability + ", Collision = " + collision;

}

public double getCommision() {

double commission = (liability + collision)*30 /100;

return commission;

}

}

//////////////////HOME POLICY//////////////////////

public class Home {

private String name; private double homesquare; private double liability; private double dwelling; private double content;

public Home() { this.name = name; this.homesquare = homesquare; this.liability = liability; this.dwelling = dwelling; this.content = content;

}

public double getCommision() {

double comSale = (liability * 0.3) + ( (dwelling + content) * 0.2 ); return comSale;

}

public String toString() {

return "Home:"+" Name = " + name + ", Homesquare = " + homesquare

+ ",Liability = " + liability + ",Dwelling = " + dwelling

+ ",Content = " + content;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public double getHomesquare() {

return homesquare;

}

public void setHomesquare(double homesquare) {

this.homesquare = homesquare;

}

public double getLiability() {

return liability;

}

public void setLiability(double liability) {

this.liability = liability;

}

public double getDwelling() {

return dwelling;

}

public void setDwelling(double dwelling) {

this.dwelling = dwelling;

}

public double getContent() {

return content;

}

public void setContent(double content) {

this.content = content;

}

}

/////////////////LIFE POLICY//////////////////

public class Life extends policy { private String name; private int age; private double term;

public Life() {

this. name = name; this.age = age; this.term = term;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public double getTerm() {

return term;

}

public void setTerm(double term) {

this.term = term;

}

public String toString() {

return "Life:"+" Name = " + name + ", Age = " + age + ", Term = " + term;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

public double getCommision() {

double comSale = term*0.2;

return comSale;

}

}

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

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

5. Prepare for the role of interviewee

Answered: 1 week ago

Question

6. Secure job interviews and manage them with confidence

Answered: 1 week ago