Repository navigation
Expand file tree
/
Copy pathCommunityRaid.java
More file actions
57 lines (50 loc) · 1.95 KB
/
Copy pathCommunityRaid.java
File metadata and controls
57 lines (50 loc) · 1.95 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
import java.io.Serializable;
public class CommunityRaid implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String title;
private String category;
private int targetCount;
private int currentCount;
private String deadline;
private String rewardDescription;
public CommunityRaid(String id, String title, String category, int targetCount, int currentCount, String deadline, String rewardDescription) {
this.id = id;
this.title = title;
this.category = category;
this.targetCount = targetCount;
this.currentCount = currentCount;
this.deadline = deadline;
this.rewardDescription = rewardDescription;
}
public String getId() { return id; }
public String getTitle() { return title; }
public String getCategory() { return category; }
public int getTargetCount() { return targetCount; }
public int getCurrentCount() { return currentCount; }
public String getDeadline() { return deadline; }
public String getRewardDescription() { return rewardDescription; }
public double getProgressPercentage() {
return Math.min(100.0, (double) currentCount / targetCount * 100.0);
}
public boolean contribute() {
if (currentCount < targetCount) {
currentCount++;
return true;
}
return false;
}
@Override
public String toString() {
int pct = (int) Math.round(getProgressPercentage());
StringBuilder bar = new StringBuilder("[");
int filled = pct / 5; // 20 segments
for (int i = 0; i < 20; i++) {
if (i < filled) bar.append("█");
else bar.append("░");
}
bar.append("]");
return String.format("%s (%s)\n Progress: %s %d%% (%d/%d shared)\n Reward: %s | %s",
title, category, bar.toString(), pct, currentCount, targetCount, rewardDescription, deadline);
}
}