Question: Now create the two subclasses of client: one called Individualclient and the other called CompanyClient. Try compiling them. Notice that your test code will not

Now create the two subclasses of client: one called Individualclient and the other called CompanyClient. Try compiling them. Notice that your test code will not compile. That's because subclasses DO NOT inherit constructors and java requires a constructor to be available. Do the following: Create a constructor (taking a single String argument) for each of these subclasses that calls the one in Client. . Go back and alter your toString() method in Client class so that the proper client type is displayed. For example: CompanyClient 0001: Bob B. Pins To do this, you will want to figure out how to get the name of the class as a String. Implement the makeClaim(int polNum) method in the Individualclient class. If the policy with that number is not found or has expired, then simply return 0. IndividualClients are allowed to make only 1 claim for a regular Policy but Depreciating Policy and ExpiringPolicy objects can have multiple claims. So, you should cancel any regular policies after a claim is made. If the claim is being made for a DepreciatingPolicy, then you must make sure to depreciate the policy. This method should return the amount of the policy amount after depreciating in the case of DepreciatingPolicy objects) if the claim made was ok, otherwise 0 is returned. . In the Policy class, implement a method called handleClaim() that returns the amount of the policy. In the DepreciatingPolicy class, implement handleClaim) so that it returns the amount of the policy but also depreciates the policy. Note that the amount returned is the amount of the policy before it was depreciated. In the ExpiringPolicy class, implement handleClaim() so that it returns the amount of the policy as long as the policy has not yet expired, otherwise it returns 0. In the CompanyClient class, implement the makeClaim(int polNum) method so that it first checks to make sure the policy is one belonging to this client and then uses the double- dispatching technique by calling the handleClaim() method. Double-dispatching is discussed in Section 4.5 of the textbook. Note that you MUST NOT use any IF statements to determine the policy type as that would undo the advantages of double-dispatching. Note that companyClient objects DO NOT have their policy removed afterwards, and so you should make use of the getPolicy() method. If no policy is found with the given polNum, return 0; Now create the two subclasses of client: one called Individualclient and the other called CompanyClient. Try compiling them. Notice that your test code will not compile. That's because subclasses DO NOT inherit constructors and java requires a constructor to be available. Do the following: Create a constructor (taking a single String argument) for each of these subclasses that calls the one in Client. . Go back and alter your toString() method in Client class so that the proper client type is displayed. For example: CompanyClient 0001: Bob B. Pins To do this, you will want to figure out how to get the name of the class as a String. Implement the makeClaim(int polNum) method in the Individualclient class. If the policy with that number is not found or has expired, then simply return 0. IndividualClients are allowed to make only 1 claim for a regular Policy but Depreciating Policy and ExpiringPolicy objects can have multiple claims. So, you should cancel any regular policies after a claim is made. If the claim is being made for a DepreciatingPolicy, then you must make sure to depreciate the policy. This method should return the amount of the policy amount after depreciating in the case of DepreciatingPolicy objects) if the claim made was ok, otherwise 0 is returned. . In the Policy class, implement a method called handleClaim() that returns the amount of the policy. In the DepreciatingPolicy class, implement handleClaim) so that it returns the amount of the policy but also depreciates the policy. Note that the amount returned is the amount of the policy before it was depreciated. In the ExpiringPolicy class, implement handleClaim() so that it returns the amount of the policy as long as the policy has not yet expired, otherwise it returns 0. In the CompanyClient class, implement the makeClaim(int polNum) method so that it first checks to make sure the policy is one belonging to this client and then uses the double- dispatching technique by calling the handleClaim() method. Double-dispatching is discussed in Section 4.5 of the textbook. Note that you MUST NOT use any IF statements to determine the policy type as that would undo the advantages of double-dispatching. Note that companyClient objects DO NOT have their policy removed afterwards, and so you should make use of the getPolicy() method. If no policy is found with the given polNum, return 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
