6 hour spent_in_month[12];
15 int operator!=(String &s);
17 void addtime(hour spent, unsigned month);
32 act_lst *timesheet, *a;
35 timesheet = new act_lst;
36 timesheet->act = new activity("TOTAL");
42 String action1, action2, datestring;
44 std::cin >> datestring;
46 d1 = date(datestring);
47 t1 = hour(datestring);
51 std::cin >> datestring;
52 d2 = date(datestring);
53 t2 = hour(datestring);
56 // process the activity from nr 1 to nr 2.
60 // No action: ends the previous action.
64 // Find the action in the list. If not found add a new activity.
66 for (a = timesheet; a && *a->act != action1; a=a->next);
70 a->act = new activity(action1);
77 std::cerr << "More than a day at " << datestring << "\n";
79 a->act->addtime(t2 - t1, d1.Month());
80 Total->act->addtime(t2 - t1, d1.Month());
83 // shift the log entry one place.
90 std::cout << "Activity\tJan\tFeb\tMar\tApr\tMay\tJun\tJul\tAug\tSep\tOct\tNov\tDec\tTOTAL\n\n";
92 for (a = timesheet; a; a = a->next)
98 int activity::operator!=(String &s)
100 return description != s;
103 void activity::addtime(hour spent, unsigned month)
105 spent_in_month[month - 1] += spent;
108 void activity::print(void)
112 std::cout << description << "\t";
113 for (int i=0; i<12; i++)
115 std::cout << spent_in_month[i] << "\t";
116 total += spent_in_month[i];
118 std::cout << total << "\t" << description << "\n";