Question: Modify your code from Project 2 using the concepts you learned from Chapter 8 . Step 1 Open jGRASP and create a new java file.

Modify your code from Project 2 using the concepts you learned from Chapter 8.
Step 1
Open jGRASP and create a new java file.
Slick File/Save As and save the file in the CSC251Project folder created in the GitHub Repository Instruction document
Name the file PolicyHolder.java
Open (or return to) GitHub Desktop. The program file added to the repository's directory should appear in the Changes column.
Click the button Commit to Project-3
Create a PolicyHolder class that will represent a person that is associated with an insurance policy.
Move the appropriate fields and methods of the Policy class into the PolicyHolder class (Hint: the fields and methods you move into the PolicyHolder class should be directly associated with a policy holder).
There should be no duplication of fields or methods in the Policy and PolicyHolder classes.
GitHub Desktop Commit (once per source file):
In the Changes window, you should see a list of all of the files you have modified
You will commit changes to each file separately
De-select all of the check boxes
Check the check box beside the PolicyHolder.java file
Commit your changes to the Project-3 branch with the description "Imported fields and methods from Policy class"
Check the check box beside the Policy.java file
Commit your changes to the Project-3 branch with the description "Moved fields and methods to the PolicyHolder" class
Step 2
Add a toString method to both the Policy and PolicyHolder classes.
GitHub Desktop Commit (once per source file): Commit your changes to each source code file separately to the Project-3 branch with the description "Added toString method"
Step 3
Add a static field that is used to keep track of the number of Policy objects that have been created.
GitHub Desktop Commit: Commit your changes to the Project-3 branch with the description "Added static field to track number of Policy objects"
Step 4
Demonstrate proper use of class collaboration in such a way that a Policy has a PolicyHolder.
Step 5
Minimize the risk of security holes in your program (Note: review the "Security Issues with Aggregate Classes" section in Chapter 8).
Step 6
Alter the Demo class to implicitly call the toString method you created in Step 2 when outputting information about the Policy objects.
Step 7
The demo program should display the number of Policy objects that were created, the number of Policyholders that are smokers, and the number of Policyholders that are non-smokers.
GitHub Desktop Commit: Commit your changes to the Project-3 branch with the description: "Added code to implicitly call toString method and output information about Policy and PolicyHolders".
After committing the last changes to the Project-3 branch, make sure to merge the changes into the main branch and push them to the remote repository (follow the same procedure that was explained in Project 1). Submit a screenshot of your remote GitHub repository (follow the same procedure that was explained in Project 1).
Sample Output
Policy Number: 3450
Provider Name: State Farm
Policyholder's First Name: Alice
Policyholder's Last Name: Jones
Policyholder's Age: 20
Policyholder's Smoking Status (Y/N): smoker
Policyholder's Height: 65.0 inches
Policyholder's Weight: 110.0 pounds
Policyholder's BMI: 18.30
Policy Price: $700.00
Policy Number: 3455
Provider Name: Aetna
Policyholder's First Name: Bob
Policyholder's Last Name: Lee
Policyholder's Age: 54
Policyholder's Smoking Status (YN): non-smoker
Policyholder's Height: 72.0 inches
Policyholder's Weight: 200.0 pounds
Policyholder's BMI: 27.12
Policy Price: $675.00
Policy Number: 2450
Provider Name: Met Life
Policyholder's First Name: Chester
Policyholder's Last Name: Williams
Policyholder's Age: 40
Policyholder's Smoking Status (Y/N): smoker
Policyholder's Height: 71.0 inches
Policyholder's Weight: 300.0 pounds
Policyholder's BMI: 41.84
Policy Price: $836.74
Policy Number: 3670
Policy Number: 3670
Provider Name: Global
Policyholder's First Name: Cindy
Policyholder's Last Name: Smith
Policyholder's Age: 55
Policyholder's Smoking Status (Y/N): non-smoker
Policyholder's Height: 62.0 inches
Policyholder's Weight: 140.0 pounds
Policyholder's BMI: 25.60
Policy Price: $675.00
Policy Number: 1490
Provider Name: Reliable
Policyholder's First Name: Jenna
Policyholder's Last Name: Lewis
Policyholder's Age: 30
Policyholder's Smoking Status (Y/N): smoker
Policyholder's Height: 60.0 inches
Policyholder's Weight: 105.0 pounds
Policyholder's BMI: 20.50
Policy Price: $700.00
Policy Number: 3477
Provider Name: State Farm
Policyholder's First Name: Craig
Policyholder's Last Name: Duncan
Policyholder's Age: 23
Policyholder's Smoking Status (Y/N): smoker
Policyholder's Height: 66.0 inches
Policyholder's Weight: 215.0 pounds
Policyholder's First Name: Craig
Policyholder's Last Name: Duncan
Policyholder's Age: 23
Policyholder's Smoking Status (Y/N): smoker
Policyholder's Height: 6
Modify your code from Project 2 using the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!