Question
JAVA Programming 1.Modify the Autopolicy(Page 184-185)program to a HealthInsurancePolicy. Create a HealthInsurancePolicyTest class to test your class. The health policy should include the followingat a
JAVA Programming 1.Modify the Autopolicy(Page 184-185)program to a HealthInsurancePolicy. Create a HealthInsurancePolicyTest class to test your class. The health policy should include the followingat a minimum:Policy Number, Name of Insurer, Name of the Insured, Age, Sex, DependentsYou can create predicate method called MandatoryInsuranceState() and assign some states.2.Create classes called Circle, Rectangle, Sphere with attributes. Create a classesnamed TestCircle, TestRectangewhose main() method declares several objects. Use the setRadius() methods like setRadius(), getRadius(),setLength() etc. toassignand extractseparate values for the different objects.Display allthe created objects.Your program should use METHODS. Page 184: n value is to begin the name with "is" rather than "get" (such a method is commonly called a predicate method). 1 // Fig. 5.11: AutoPolicy.java 2 // Class that represents an auto insurance policy. 3 public class AutoPolicy { 4 private int accountNumber; // policy account number 5 private String makeAndModel; // car that the policy applies to 6 private String state; // two-letter state abbreviation 7 8 // constructor 9 public AutoPolicy(int accountNumber, String makeAndModel, 10 String state) { 11 this.accountNumber = accountNumber; 12 this.makeAndModel = makeAndModel; 13 this.state = state; 14 } 15 16 // sets the accountNumber 17 public void setAccountNumber(int accountNumber) { 18 this.accountNumber = accountNumber; 19 } 20 21 // returns the accountNumber 22 public int getAccountNumber() { 23 return accountNumber; 24 } 25 26 // sets the makeAndModel 27 public void setMakeAndModel(String makeAndModel) { 28 this.makeAndModel = makeAndModel; 29 } 30 31 // returns the makeAndModel 32 public String getMakeAndModel() { 33 return makeAndModel; 34 } 35 36 // sets the state 37 public void setState(String state) { 38 this.state = state; 39 } 40 41 // returns the state 42 public String getState() { 43 return state; 44 } 45 46 // predicate method returns whether the state has no-fault insurance 47 public boolean isNoFaultState(){ 48 boolean noFaultState; 49 50 // determine whether state has no-fault auto insurance 51 switch (getState()) { // get AutoPolicy object's state abbreviation 52 case "MA": case "NJ": case "NY": case "PA": 53 noFaultState = true; 54 break; 55 default: 56 noFaultState = false; 57 break; 58 } 59 60 return noFaultState; 61 } 62 }
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