-
Notifications
You must be signed in to change notification settings - Fork 0
/
User.java
67 lines (61 loc) · 2.4 KB
/
User.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import java.util.ArrayList;
import java.util.List;
public class User {
private String username, password;
private boolean hasPlayed;
private int totPlayed, totWon, lastResult, lastStreak, bestStreak; //lastResult : won or lost.
private List<Integer> guessDistribution;
User (String username, String password) {
//per l'inserimento la prima volta.
this.username = username;
this.password = password;
this.totPlayed = 0;
this.totWon = 0;
this.lastResult = -1; //none
this.lastStreak = 0;
this.bestStreak = 0;
this.guessDistribution = new ArrayList<>();
this.hasPlayed = false;
}
User (String username, String password, boolean hasPlayed, int totPlayed, int totWon, int lastResult, int lastBestWon, int absoluteBestWon, List<Integer> guessDistribution) {
// Per la deserializzazione dal file json
this.username = username;
this.password = password;
this.totPlayed = totPlayed;
this.totWon = totWon;
this.lastResult = lastResult;
this.lastStreak = lastBestWon;
this.bestStreak = absoluteBestWon;
this.guessDistribution = guessDistribution;
this.hasPlayed = hasPlayed;
}
public String getPassword() { return this.password; }
public String getUsername() {
return this.username;
}
public boolean getHasPlayed () { return this.hasPlayed; }
public void setHasPlayed (boolean val) { this.hasPlayed = val; }
public int getTotPlayed() {
return totPlayed;
}
public int getTotWon() { return totWon; }
public int getLastResult() { return lastResult; }
public int getLastStreak() {
return lastStreak;
}
public int getBestStreak() {
return bestStreak;
}
public List<Integer> getGuessDistribution() {
return guessDistribution;
}
public void incrementPlayed () { this.totPlayed++; }
public void incrementWon () { this.totWon++; }
public void setLastResult (int val) { this.lastResult = val; }
public void incrementLastStreak () { this.lastStreak++; }
public void setBestStreak (int lastBestWon) { this.bestStreak = lastBestWon; }
public void resetLastStreak () { this.lastStreak = 1; }
public void guessDistributionAdd (int r) {
this.guessDistribution.add(r);
}
}