-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoPolicy.java
More file actions
57 lines (47 loc) · 1.58 KB
/
Copy pathAutoPolicy.java
File metadata and controls
57 lines (47 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
public class AutoPolicy {
private int accountNumber;
private String makeAndModel;
private String state;
public AutoPolicy(int accountNumber, String makeAndModel, String state) {
this.accountNumber = accountNumber;
this.makeAndModel = makeAndModel;
this.state = state;
}
public int getAccountNumber() {
return accountNumber;
}
public String getMakeAndModel() {
return makeAndModel;
}
public String getState() {
return state;
}
public boolean isNoFaultState() {
switch (state) {
case "CT": // Connecticut
case "MA": // Massachusetts
case "NH": // New Hamphsire
case "NJ": // New Jersey
case "NY": // New York
case "PA": // Pennsylvania
case "VT": // Vermont
return true;
default:
return false;
}
}
public static void policyInNoFaultState(AutoPolicy policy) {
System.out.println("The auto policy:");
System.out.printf("Account: %d; Car: %s; %nState %s %s a no-fault state.%n%n",
policy.getAccountNumber(),
policy.getMakeAndModel(),
policy.getState(),
(policy.isNoFaultState() ? "is" : "is not"));
}
public static void main(String[] args) {
AutoPolicy policy1 = new AutoPolicy(11111, "Toyota Camry", "NJ");
AutoPolicy policy2 = new AutoPolicy(22222, "Ford Fusion", "ME");
policyInNoFaultState(policy1);
policyInNoFaultState(policy2);
}
}