File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 22
33import warranty .Contract .Status ;
44
5+ import java .util .Date ;
6+
57/**
68 * Adjudicate/adjudication - a judgment made on a claim to determine whether
79 * we are legally obligated to process the claim against the warranty. From
1416public class ClaimsAdjudication {
1517
1618 public void Adjudicate (Contract contract , Claim newClaim ) {
17- double claimTotal = contract .getClaims ().stream ().mapToDouble (c -> c .amount ).sum ();
18- if (((contract .purchasePrice - claimTotal ) * 0.8 > newClaim .amount ) &&
19- (contract .status == Status .ACTIVE ) &&
20- (newClaim .failureDate .compareTo (contract .effectiveDate ) >= 0 ) &&
21- (newClaim .failureDate .compareTo (contract .expirationDate ) <= 0 )) {
19+ if ((LimitOfLiability (contract ) > newClaim .amount ) &&
20+ InEffectFor (contract , newClaim .failureDate )) {
2221 contract .add (newClaim );
2322 }
2423 }
24+
25+ // These two new methods we've added seem to be responsibilities of Contract. Let's move them...
26+ public double LimitOfLiability (Contract contract ) {
27+ double claimTotal = contract .getClaims ().stream ().mapToDouble (c -> c .amount ).sum ();
28+ return (contract .purchasePrice - claimTotal ) * 0.8 ;
29+ }
30+
31+ public boolean InEffectFor (Contract contract , Date failureDate ) {
32+ return (contract .status == Status .ACTIVE ) &&
33+ (failureDate .compareTo (contract .effectiveDate ) >= 0 ) &&
34+ (failureDate .compareTo (contract .expirationDate ) <= 0 );
35+ }
2536}
You can’t perform that action at this time.
0 commit comments