-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPair.java
More file actions
53 lines (43 loc) · 1021 Bytes
/
Copy pathPair.java
File metadata and controls
53 lines (43 loc) · 1021 Bytes
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
/**
This class describes a simple Pair class for storing character/double pairs. Used for A4 from previous version.
*/
public class Pair implements Comparable<Pair>{
// declare all required fields
private char value;
private double prob;
/**
Constructor 1
All args accounted for
*/
public Pair(char v, double p){
value = v;
prob = p;
}
public void setValue(char v){
value = v;
}
public void setProb(double p){
prob = p;
}
public char getValue(){
return value;
}
public double getProb(){
return prob;
}
/**
The compareTo method overrides the compareTo method of the Comparable
interface.
*/
@Override
public int compareTo(Pair p){
return Double.compare(this.getProb(), p.getProb());
}
/**
The toString method overrides the toString method of the Object class.
*/
@Override
public String toString(){
return value+" : "+prob;
}
}