Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. The Drive-Rite Insurance Company provides automobile insurance policies for d

ID: 3862503 • Letter: 2

Question

2. The Drive-Rite Insurance Company provides automobile insurance policies for drivers. Design a single class diagram showing the class, the application program, the relationship between the two, and multiplicity. Insert the completed class diagram into a Word document. Then write the pseudocode as described below. a. Create a PolicyHolder class that contains a policy number, customer age, and the number of accidents in which the driver has been involved in the last three years. Include the following: i. A default constructor that initializes each attribute to some reasonable default value for a non-existent policy holder. ii. Another constructor method that has a parameter for each data member, called the overloaded constructor. This constructor initializes each attribute to the value provided when an object of this type is instantiated. If the customer's age is not between 14 and 125 inclusive, then display an error message and set the age to 0. iii. Accessor and mutator methods for each attribute. For the age mutator, if the customer's age is not between 14 and 125 inclusive, then set the age to 0, since this is obviously an error. iv. Amethod that displays all the data about a policy holder.

Explanation / Answer

/** * @fileName PolicyHolder.java * @author * @since 16/3/17 */ public class PolicyHolder { private int policyNumber; private int age; private int numberOfAccident; /** * Default constructor which initialize the object with default values */ public PolicyHolder() { this.policyNumber = 0; this.age = 24; this.numberOfAccident = 0; } /** * This is parametrized (overloaded) constructor which will initialize the PolicyHolder object * @param policyNumber * @param age * @param numberOfAccident */ public PolicyHolder(int policyNumber, int age, int numberOfAccident) { this.policyNumber = policyNumber; this.age = age; this.numberOfAccident = numberOfAccident; } public int getPolicyNumber() { return policyNumber; } public int getAge() { return age; } public int getNumberOfAccident() { return numberOfAccident; } public void setPolicyNumber(int policyNumber) { this.policyNumber = policyNumber; } public void setAge(int age) { this.age = age; } public void setNumberOfAccident(int numberOfAccident) { this.numberOfAccident = numberOfAccident; } @Override public String toString() { return "PolicyHolder{" + "policyNumber=" + policyNumber + ", age=" + age + ", numberOfAccident=" + numberOfAccident + '}'; } } /** * @fileName CheckPolicyHolder.java * @author * @since 15/3/17 */ public class CheckPolicyHolder { /** *This function accept * @param policyHolder */ public static void checkAccident(PolicyHolder policyHolder){ if(policyHolder.getAge()>=35 && policyHolder.getNumberOfAccident()
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote