Archived
first commit
This commit is contained in:
commit
1e19e7f773
7 files changed
+173
No files matched your search
@@ -0,0 +1,49 @@
|
||||
public class ActivityLog {
|
||||
private int actMins;
|
||||
private int longest;
|
||||
private int longestHigh;
|
||||
|
||||
|
||||
public void log(int minutes, boolean high) {
|
||||
if(high) {
|
||||
actMins += 2 * minutes;
|
||||
if(minutes > longestHigh) {
|
||||
longestHigh = minutes;
|
||||
}
|
||||
} else {
|
||||
actMins += minutes;
|
||||
}
|
||||
|
||||
longest = Math.max(longest, minutes);
|
||||
}
|
||||
|
||||
public int longest(boolean highOnly) {
|
||||
return highOnly ? longestHigh : longest;
|
||||
}
|
||||
|
||||
public int activeMinutes() {
|
||||
return actMins;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ActivityLog a = new ActivityLog();
|
||||
System.out.println(a.activeMinutes());
|
||||
System.out.println(a.longest(false));
|
||||
System.out.println(a.longest(true));
|
||||
System.out.println();
|
||||
|
||||
a.log(45, false);
|
||||
a.log(30, true);
|
||||
a.log(30, true);
|
||||
System.out.println(a.activeMinutes());
|
||||
System.out.println(a.longest(false));
|
||||
System.out.println(a.longest(true));
|
||||
System.out.println();
|
||||
|
||||
a.log(50, true);
|
||||
a.log(30, false);
|
||||
System.out.println(a.activeMinutes());
|
||||
System.out.println(a.longest(false));
|
||||
System.out.println(a.longest(true));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user