-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRating.java
More file actions
97 lines (89 loc) · 2.57 KB
/
Copy pathRating.java
File metadata and controls
97 lines (89 loc) · 2.57 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* Write a description of class Rating here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Rating
{
private String name;
private double quality;
private String av_grade;
private double helpfulness;
private double clarity;
private double easiness;
public Rating(){
}
public Rating(double quality, double helpfulness, double clarity, double easiness){
this.quality = quality;
this.helpfulness = helpfulness;
this.clarity = clarity;
this.easiness = easiness;
}
public double getQuality(){
return quality;
}
public double getHelpfulness(){
return helpfulness;
}
public double getClarity(){
return clarity;
}
public double getEasiness(){
return easiness;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public void setQuality(double quality){
this.quality = quality;
}
public void setHelpfulness(double helpfulness){
this.helpfulness = helpfulness;
}
public void setClarity(double clarity){
this.clarity = clarity;
}
public void setEasiness(double easiness){
this.easiness = easiness;
}
public void setAv_grade(String grade){
this.av_grade = grade;
}
public boolean isValid(){
if (quality > -1 && helpfulness > -1 && clarity > -1 && easiness > -1){
return true;
}
else {
return false;
}
}
public double findDistance(Rating r){
double distance = Math.abs(r.quality - quality);
distance += Math.abs(r.helpfulness - helpfulness);
distance += Math.abs(r.clarity - clarity);
distance += Math.abs(r.easiness - easiness);
return distance;
}
public boolean valueEquals(Rating r){
if (quality == r.quality && helpfulness == r.helpfulness && clarity == r.clarity && easiness == r.easiness){
return true;
}
return false;
}
public String toString(){
String stringrep = "";
stringrep += "Quality is " + quality;
stringrep += "\nHelpfulness is " + helpfulness;
stringrep += "\nClarity is " + clarity;
stringrep += "\nEasiness is " + easiness;
stringrep += "\nTotal Score is " + (quality + helpfulness + clarity + easiness);
return stringrep;
}
public double getLength(){
return (quality + helpfulness + clarity + easiness)/4;
}
}