-
Notifications
You must be signed in to change notification settings - Fork 0
/
StyleRanking.java
52 lines (42 loc) · 1.47 KB
/
StyleRanking.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.lang.Exception;
import static java.lang.Math.abs;
class StyleRanking{
public static final int MAX_RANK = 8;
public int rank = -8;
public int progress = 0;
public void incProgress(int activityRank) throws IllegalArgumentException{
if (activityRank == 0 || activityRank > 8 || activityRank < -8) {
throw new IllegalArgumentException();
}
if(this.rank==8){
this.progress=0;
}
else if (this.rank == activityRank) {
progress += 3;
} else if (this.rank == activityRank + 1||(activityRank==-1&&this.rank==activityRank+2)) {
progress += 1;
} else if (this.rank > activityRank + 1) {
progress += progress;
} else {
int rankDiff = abs(this.rank - activityRank);
if ((activityRank > 0 && this.rank < 0)||(activityRank < 0 && this.rank > 0)) {
rankDiff -= 1;
}
int multiplier = rankDiff * rankDiff;
progress += (10 * multiplier);
}
while (progress >= 100) {
this.progress = progress - 100;
if (rank == -1) {
rank += 2;
} else if (rank == 8) {
} else {
rank++;
}
}
if(this.rank==8){
this.progress=0;
}
System.out.println("rank:"+this.rank+"---"+"progress: "+this.progress);
}
}