Line | |
---|
1 | package geniusweb.blingbling;
|
---|
2 |
|
---|
3 | public class ValueTracker {
|
---|
4 | private int valueCount = 0;
|
---|
5 | private double evaluation = 0.0;
|
---|
6 |
|
---|
7 | public int incrementGet() {
|
---|
8 | return ++valueCount;
|
---|
9 | }
|
---|
10 |
|
---|
11 | public void updateEvaluation(int maxValueCount, double weight) {
|
---|
12 | if (weight < 1.0) {
|
---|
13 | double modValueCount = Math.pow(((double) valueCount + 1.0), (1.0 - weight)) - 1.0;
|
---|
14 | double modMaxValueCount = Math.pow(((double) maxValueCount + 1.0), (1.0 - weight)) - 1.0;
|
---|
15 |
|
---|
16 | evaluation = modValueCount / modMaxValueCount;
|
---|
17 | } else {
|
---|
18 | evaluation = 1.0;
|
---|
19 | }
|
---|
20 | }
|
---|
21 |
|
---|
22 | public double getEvaluation() {
|
---|
23 | return evaluation;
|
---|
24 | }
|
---|
25 |
|
---|
26 | public int getCount() {
|
---|
27 | return valueCount;
|
---|
28 | }
|
---|
29 |
|
---|
30 | public String toString() {
|
---|
31 | return "(" + String.valueOf(valueCount) + ") " + String.valueOf(evaluation);
|
---|
32 | }
|
---|
33 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.