-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomerPriorityComparator.java
More file actions
65 lines (43 loc) · 1.24 KB
/
Copy pathCustomerPriorityComparator.java
File metadata and controls
65 lines (43 loc) · 1.24 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
58
59
60
61
62
63
64
65
import java.util.Scanner;
import java.util.*;
public class CustomerPriorityComparator implements Comparator<Customer> {
private String name;
private int customerID;
private CreditHistory history;
public CustomerPriorityComparator(){
name = "";
customerID = 0;
}
public int compare(Customer a, Customer b) {
int rating0 = (int) a.getCreditHistory().getCreditRating();
int rating1 = (int) b.getCreditHistory().getCreditRating();
if(rating0 == rating1 ) {
return 0;
}
else if (rating0 < rating1) {
return 1;
}
else {
return -1;
}
}
public String getName(){
String copyName = name;
return copyName;
}
public void setName(String newName){
name = newName;
}
public void setCustomerID(int newID){
customerID = newID;
}
public int getCustomerID(){
int copyID = customerID;
return copyID;
}
public String toString(){
String customerIDstring = Integer.toString(customerID);
String customerString = name+" "+customerIDstring;
return customerString;
}
}