-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
executable file
·46 lines (33 loc) · 1.11 KB
/
Main.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
import entity.WorkLog;
import java.util.Calendar;
import java.util.Date;
class Main
{
public static void main(String[] args)
{
saveWorklogForStartingDay(new WorkLog());
if (args.length == 0 || Integer.parseInt(args[0]) <= Calendar.getInstance().get(Calendar.HOUR_OF_DAY)) {
System.out.println("Usage: java Main <Finish hour 24h format>");
System.err.println("The end hour is required");
System.err.println("The finish hour should be greater than current hour.");
System.exit(1);
}
Promter promter = new Promter();
int minutesToWait = (args.length == 2)? Integer.parseInt(args[1]): 30;
do {
WorkLog wlog = new WorkLog();
promter.wait(minutesToWait);
Panel frame = new Panel(400,200, wlog);
promter.prompt(frame);
} while ( Integer.parseInt(args[0]) > Calendar.getInstance().get(Calendar.HOUR_OF_DAY));
}
private static void saveWorklogForStartingDay(WorkLog wlog) {
wlog.setTask("started");
wlog.setDescription("Day started");
wlog.setFinishedAt(new Date());
wlog.setDuration(0);
Storage ss = new CsvWriter();
ss.addColumns(wlog.valuesToArray());
ss.save();
}
}