-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserProfile.java
57 lines (53 loc) · 1.57 KB
/
UserProfile.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
//Stores user profile information and scores
import java.util.HashMap;
import java.nio.file.Paths;
import java.util.Map.Entry;
public class UserProfile
{
//add profile pic reference/name?
public static String rescProfilePath = "resc/profile/";
public static String profileImagePath = "resc/profile/user_default_image.png"; //only initial var contains folder path
//add username
public static String userName = "Cletus Jackson"; //TODO: Either make TextField or create user profile edit dialog box
public static HashMap<String, Integer> scores = new HashMap<String, Integer>();
public static String getProfileImagePath(){
return profileImagePath;
}
public static void setProfileImagePath(String imageName){
profileImagePath = rescProfilePath + imageName;
}
public static void addScore(String key, int value)
{
if(scores.containsKey(key) && value <= scores.get(key)) {
return; //if higher score already exists, do not change
}
else {
scores.put(key, value);
RewardHelper.calculateRewards();
}
}
public static int getScore(String key) {
if(!scores.containsKey(key)) {
return 0;
}
else {
return scores.get(key);
}
}
public static int[] getProgressByGrade(){
int[] gradeProgress = new int[5];
//System.out.println("ee");
for( Entry<String, Integer> kv : scores.entrySet() ){
String temp = kv.getKey().substring(1,2);
if(temp.equals(GUI.GRADE_K))
{
gradeProgress[0] += 1;
}
else
{
gradeProgress[ Integer.parseInt(temp) ] += 1;
}
}
return gradeProgress;
}
}