-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
48 lines (37 loc) · 1.19 KB
/
Student.java
File metadata and controls
48 lines (37 loc) · 1.19 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
package officialInternalAssessment;
import java.util.ArrayList;
import java.util.List;
public class Student extends User {
public static class PracticeAttempt {
String topic;
int score;
int timeTaken;
public PracticeAttempt(String topic, int score, int timeTaken) {
this.topic = topic;
this.score = score;
this.timeTaken = timeTaken;
}
@Override
public String toString() {
return topic + "," + score + "," + timeTaken;
}
public static PracticeAttempt fromString(String s) {
String[] p = s.split(",");
return new PracticeAttempt(p[0], Integer.parseInt(p[1]), Integer.parseInt(p[2]));
}
}
private List<PracticeAttempt> history = new ArrayList<>();
public Student(String username, String password) {
super(username, password, "student");
}
public List<PracticeAttempt> getHistory() {
return history;
}
public void addAttempt(String topic, int score, int time) {
history.add(new PracticeAttempt(topic, score, time));
}
@Override
public boolean isStudent() {
return true;
}
}