-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudySession.java
More file actions
34 lines (27 loc) · 986 Bytes
/
StudySession.java
File metadata and controls
34 lines (27 loc) · 986 Bytes
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
import java.time.LocalDate;
public class StudySession {
private int id;
private String subject;
private int durationSeconds;
private LocalDate date;
public StudySession(int id, String subject, int durationSeconds, LocalDate date) {
this.id = id;
this.subject = subject;
this.durationSeconds = durationSeconds;
this.date = date;
}
public int getId() { return id; }
public String getSubject() { return subject; }
public int getDurationSeconds() { return durationSeconds; }
public LocalDate getDate() { return date; }
private String formatTime(int totalSeconds) {
int hours = totalSeconds / 3600;
int minutes = (totalSeconds % 3600) / 60;
int seconds = totalSeconds % 60;
return hours + "h " + minutes + "m " + seconds + "s";
}
@Override
public String toString() {
return id + " | " + subject + " | " + formatTime(durationSeconds) + " | " + date;
}
}