-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForest.java
More file actions
executable file
·53 lines (46 loc) · 907 Bytes
/
Forest.java
File metadata and controls
executable file
·53 lines (46 loc) · 907 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
/**
*
* @author Jude Murphy
*
*/
public class Forest implements Comparable<Forest>
{
private int root;
private double frequency;
public Forest ()
{
root = 0;
frequency = 0.0;
}
public Forest (double frequency, int root)
{
this.frequency = frequency;
this.root = root;
}
public int getRoot()
{
return root;
}
public void setRoot(int root)
{
this.root = root;
}
public double getfrequency()
{
return frequency;
}
public void setfrequency(double frequency)
{
this.frequency = frequency;
}
@Override
public int compareTo(Forest otherForest)
{
return new Double(this.frequency).compareTo(new Double(otherForest.frequency));
}
// *** USE THIS SPECIFIC TO STRING METHOD FOR DECODING LATER ON
public String toString()
{
return "ForestObject [frequency=" + frequency + ", root=" + root + "]";
}
}