aleheux-tc
/
Java-Programming-and-Software-Engineering-Fundamentals-Java-Programming-Build-a-Recommendation-Syst
Public
forked from mxc19912008/Java-Programming-and-Software-Engineering-Fundamentals-Java-Programming-Build-a-Recommendation-Syst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rating.java
32 lines (26 loc) · 834 Bytes
/
Rating.java
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
// An immutable passive data object (PDO) to represent the rating data
public class Rating implements Comparable<Rating> {
private String item;
private double value;
public Rating (String anItem, double aValue) {
item = anItem;
value = aValue;
}
// Returns item being rated
public String getItem () {
return item;
}
// Returns the value of this rating (as a number so it can be used in calculations)
public double getValue () {
return value;
}
// Returns a string of all the rating information
public String toString () {
return "[" + getItem() + ", " + getValue() + "]";
}
public int compareTo(Rating other) {
if (value < other.value) return -1;
if (value > other.value) return 1;
return 0;
}
}