Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Test Harness: /* * This is a test harness for the Policy hierarchy, Annuity, and the BookValue interface. * * This process begin by building

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Test Harness:

/* * This is a test harness for the Policy hierarchy, Annuity, and the BookValue interface. * * This process begin by building an array of objects that implement the BookValue interface. * These include HomeOwners, Auto, and Annuity objects. Objects will be instantiated directly * into an array. * * The array will be processed three times - each loop executing a specific function. * 1. Output the toString return for each object. * 2. Output (and accumulate) the current financial exposure for each object. * Output the accumulated exposure for all objects. * 3. Output (and accumulate) the current cash or book value for each object. * Output the accumulated cash value for all objects. * * */ public class Test_Policy_BookValue { /* * Global scoping for variables/data structures is STRONGLY DISCOURAGED, but here it makes * our lives (and code) simpler, so we'll allow it. * COMPLETE THE FOLLOWING ARRAY DECLARATION */ private static BookValue[] bookValues = new BookValue[6]; /* * The main method will only 'direct traffic' from this point forward. * This main calls one method to build/load the array and a second method to process it. */ public static void main( String[] args ) { buildArray( ); reviewArray( ); } // end main /* * The buildArray method instantiates 6 objects and stores them in the globally declared array. */ private static void buildArray( ) { // First, we're going to set up int arrays for our Auto limits... // This is a simpler method than trying to instantiate the arrays in the contructor calls... int[] std = {50,50,100}; int[] hiVal = {100,100,250}; // Add HomeOwner objects to the array bookValues[0] = new HomeOwners( "Ted Arroway", "Ted Arroway", "HO658542", 2563.58, "Lacy Lane, BLK 5, LOT 8", 1, 200, 25, 0.015, false ); bookValues[1] = new HomeOwners( "Drumlin, LLC", "David Drumlin", "HO963214", 5980.73, "Silicon Heights, BLK1 , Lot 1", 4, 1200, 250, 0.03, true ); // Add Auto objects to the array bookValues[2] = new Auto( "Eleanor Arroway", "Eleanor Arroway", "AU002584", 1503.27, "Jeep Wrangler", 1998, "CHRJ99W541230", std, 500 ); bookValues[3] = new Auto( "Palmer Joss", "Palmer Joss", "AU456852", 3103.79, "BMW X3", 2016, "BWMX163415872", hiVal, 1000 ); // Add Annuity objects to the array bookValues[4] = new Annuity( "Ted Arroway", "Eleanor Arroway", "5482361597", 100000, 83462.47 ); bookValues[5] = new Annuity( "S. R. Hadden", "SETI", "8543269716", 2500000, 1803957.41 ); } // end buildArray /* * The reviewArray method will call three other methods. Each called method executes a * specific function across each object in the array. */ private static void reviewArray( ) { printToStrings( ); calculateExposures( ); calculateCurrValues( ); } // end reviewArray /* * The printToStrings method will use an enhanced for loop to retrieve and output the toString * return for each object in the array. */ private static void printToStrings( ) { System.out.printf( "%n%nList of Policy Objects in Array bookValues%n%n" ); // Add the control statement for the ENHANCED FOR LOOP here for( BookValue oneContract: bookValues ) { System.out.printf( "%s%n", oneContract.toString( ) ); } // end for loop } // end printToStrings /* * The calculateExposures method will use an enhanced for loop to retrieve and output the calculateExposure * return for each object in the array. * An accumulator (totalExposure) is declared, and each object's calculateExposure value is added to the * accumulator within the loop. * When the loop completes, the total accumulated exposure value is output. */ private static void calculateExposures( ) { System.out.printf( "%n%n%n\tContract Exposures%n%n" ); // declare and initialize an accumulator double totalExposure = 0.0; // Add the control statement for the ENHANCED FOR LOOP here for( BookValue oneContract: bookValues ) { // retrieve the exposure value double currExposure = oneContract.calcExposure( ); // output a report line including the exposure value System.out.printf( "Contract %-10s $%,13.2f%n", oneContract.identifyContract( ), currExposure ); // accumulate exposure values totalExposure = totalExposure + currExposure; } // end for loop // Output total accumulated exposure System.out.printf( "%n\t\tTotal Exposure is $%,.2f%n%n", totalExposure ); } // end calculateExposures /* * The calculateCurrValues method will use an enhanced for loop to retrieve and output the calcCurrentValue * return for each object in the array. * An accumulator (totalBook) is declared, and each object's calcCurrentValue value is added to the * accumulator within the loop. * When the loop completes, the total accumulated book value value is output. */ private static void calculateCurrValues( ) { System.out.printf( "%n%n%n\tContract Book Values%n%n" ); double totalBook = 0.0; // Add the control statement for the ENHANCED FOR LOOP here for( BookValue oneContract: bookValues ) { // retrieve the exposure value double currBook = oneContract.calcCurrentValue( ); System.out.printf( "Contract %-10s $%,13.2f%n", oneContract.identifyContract( ), currBook ); // accumulate book values totalBook = totalBook + currBook; } // end for loop // Output total accumulated book value System.out.printf( "%n\t\tTotal Book Value is $%,.2f%n%n", totalBook ); } } // end Test_Policy_BookValue 

Policy(NEED TO EDIT TO FIR UML)-\

/* * This class will describe a policy object representing * an owner's policy */ public class Policy { /* * INSTANCE VARIABLES */ private String owner; // Policy owner's full, legal private String insured; // Full, legal name of named insured on policy private String polNbr; // Unique identifer for specific policy private int polType; // Interger coed indected type of poicy: ' //1: Auto //2:Homeowners private double polPrem; //Annual premium amount for policy /* * CONSTRUCTORS */ public Policy( ) { //NO code required here.. } // End null consturctor public Policy( String own, String insd, String nbr, int type, double prem ) { setOwner( own ); setInsured( insd ); setPolNbr( nbr ); setPolType( type ); setPolPrem( prem ); } // end full Contrutor /* * Set Methods */ public final void setOwner( String own ) { owner = own; } // End setOwner public final void setInsured ( String insd ) { insured = insd; } // End setInsured public final void setPolNbr (String nbr ) { polNbr = nbr; } // End setPolNbr public final void setPolType( int type ) { polType = type; } // End setPolType public final void setPolPrem( double prem ) { polPrem = prem; } // End setPolPrem /* * GET METHODS */ public final String getOwner( ) { return owner; } // End getOwner public final String getInsured( ) { return insured; } // End getInsured public final String getPolNbr( ) { return polNbr; } // End getpolNbr public final int getPolType ( ) { return polType; } // End getPolType public final double getPolPrem( ) { return polPrem; } // End getPolPrem

/* * OTHER METHODS */ public String txtPolType() { if (polType == 1) // If else to set polType { return "AUTO"; } else { return "HOMEOWNERS"; } // End if ... else } // End txtPolType public String toString () { // Return a verbose description of the object, displaying all // instance values return String.format ("%s owns Policy %s, a(n) %s policy, insuring %s, with a premnium of $%,.2f.%n", getOwner( ), getPolNbr( ), txtPolType( ), getInsured ( ), getPolPrem( ) ); } // End toString } // End Policy

Expected Output:

List of Policy Objects in Array

bookValues

Ted Arroway owns Policy HO658542, insuring Ted Arroway, with a premium of $2,563.58.This HomeOwners policy insures a type 1 home at Lacy Lane, BLK 5, LOT 8. The structure is insured for $200,000.00;contents for $25,000.00. The deductible is $3,375.00. This policy is not part of an Umbrella contract.

Drumlin, LLC owns Policy HO963214, insuring David Drumlin, with a premium of $5,980.73.This HomeOwners policy insures a type 4 home at Silicon Heights, BLK1 , Lot 1. The structure is insured for$1,200,000.00; contents for $250,000.00. The deductible is $43,500.00. This policy is part of anUmbrella contract.

Eleanor Arroway owns Policy AU002584, insuring Eleanor Arroway, with a premium of $1,503.27.This Auto policy insures a 1998 Jeep Wrangler, VIN CHRJ99W541230, with limits of Collision: $50,000.00, Comprehensive:$50,000.00, UIM: $100,000.00 and a deductible of $500.00.

Palmer Joss owns Policy AU456852, insuring Palmer Joss, with a premium of $3,103.79.This Auto policy insures a 2016 BMW X3, VIN BWMX163415872, with limits of Collision: $100,000.00, Comprehensive:$100,000.00, UIM: $250,000.00 and a deductible of $1,000.00.

Ted Arroway owns an Annuity contract, 5482361597, benefitting Eleanor Arroway. Total contract value is $100,000.00. Current cash value is $83,462.47.

S. R. Hadden owns an Annuity contract, 8543269716, benefitting SETI. Total contract value is $2,500,000.00. Currentcash value is $1,803,957.41.

Contract Exposures

Contract HO658542 $ 225,000.00

Contract HO963214 $ 1,450,000.00

Contract AU002584 $ 200,000.00

Contract AU456852 $450,000.00

Contract 5482361597 $ 16,537.53

Contract 8543269716 $ 696,042.59

Total Exposure is $3,037,580.12

Contract Book Values

Contract HO658542 $ 2,001.08

Contract HO963214 $ 2,355.73

Contract AU002584 $ 483.27

Contract AU456852 $ 808.79

Contract 5482361597 $ 83,462.47

Contract 8543269716 $ 1,803,957.41

Total Book Value is $1,893,068.75

Testing Your Submitting Your Work Given: UML Class Diagrams o Policy o Auto . o HomeOwners o Annuity o o Bookvalue NOTE: Highlighted operations in Policy, Auto, Homeowners, and Annuity are interface methods. Test harness shell: Test_Policy_Bookvalue.java . These instructions Sample output . Grading Rubric Tasks: 1. Modify Policy from PAO1 so that it meets the revised requirements, as described in the UML 2. Code the interface Bookvalue to meet the UML requirements provided. 3. Code the new subclasses, Auto and Homeowners, to meet the UML requirements provided. 4. Code the new class Annuity to meet the UML requirements provided. 5. Test your code using the provided test harness. ;s

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

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions