Neighbour.java
1.92 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
package com.lotus.town.neighgour;
import java.math.BigDecimal;
public class Neighbour {
int id;
String name;
int head;
int jumpCount;
double money;
double todayMoney;
public Neighbour(int id, String name, int jumpCount, int head, double money, double todayMonkey) {
this.id = id;
this.name = name;
this.jumpCount = jumpCount;
this.head = head;
this.money = money;
this.todayMoney = todayMonkey;
BigDecimal bg = new BigDecimal(this.money);
this.money = bg.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
bg = new BigDecimal(this.todayMoney);
this.todayMoney = bg.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
}
@Override
public String toString() {
return "Neighbour{" +
"id=" + id +
", name='" + name + '\'' +
", head=" + head +
", jumpCount=" + jumpCount +
", money=" + money +
", todayMoney=" + todayMoney +
'}';
}
String getData() {
return name + "," + jumpCount + "," + money + "," + todayMoney;
}
void earn(double monkey) {
this.money += monkey;
this.todayMoney += monkey;
BigDecimal bg = new BigDecimal(this.money);
this.money = bg.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
bg = new BigDecimal(this.todayMoney);
this.todayMoney = bg.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
}
String getKey() {
return String.valueOf(id);
}
public String getName() {
return name;
}
public int getJumpCount() {
return jumpCount;
}
public double getMoney() {
return money;
}
public double getTodayMoney() {
return todayMoney;
}
public int getHead() {
return head;
}
public int getId() {
return id;
}
}