-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProfile.java
More file actions
98 lines (74 loc) · 2.25 KB
/
Profile.java
File metadata and controls
98 lines (74 loc) · 2.25 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
98
package org.cleancode.journal.domain;
import com.vaadin.flow.spring.annotation.VaadinSessionScope;
import org.cleancode.journal.domain.grade.GradeColor;
import org.cleancode.journal.domain.grade.GradeTopic;
import org.springframework.stereotype.Component;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.*;
@Component
@VaadinSessionScope
public class Profile implements Serializable {
private GradeColor currentGrade = GradeColor.Red;
private Score score = new Score();
private String name = "Alex"; //start with sample data
private LocalDate stared = LocalDate.now();
private int level = 1;
private Set<String> favoriteTopicIds = new HashSet<>();
private List<LogEntry> log = new LinkedList<>();
public Profile() {
score.setExperience(42); //start with sample data
}
public LocalDate getStared() {
return stared;
}
public void setStared(LocalDate stared) {
this.stared = stared;
}
public void addScore(Score score) {
this.score.add(score);
}
public void addExperience(int experience) {
getScore().setExperience(getScore().getExperience() + experience);
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public Score getScore() {
return score;
}
public GradeColor getCurrentGrade() {
return currentGrade;
}
public boolean hasFavorite(GradeTopic topic) {
return favoriteTopicIds.contains(topic.getId());
}
public void addFavorite(GradeTopic topic) {
favoriteTopicIds.add(topic.getId());
}
public void removeFavorite(GradeTopic topic) {
favoriteTopicIds.remove(topic.getId());
}
public Collection<String> getFavoriteTopicIds() {
return favoriteTopicIds;
}
public List<LogEntry> getLog() {
return log;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void addLogEntry(LogEntry logEntry) {
log.add(logEntry);
addScore(logEntry.getScore());
}
public void setCurrentGrade(GradeColor currentGrade) {
this.currentGrade = currentGrade;
}
}