updated standalone classes

This commit is contained in:
2025-08-11 11:12:42 +02:00
parent 1f1e06a8e1
commit f0bda09710
3 changed files with 68 additions and 26 deletions

View File

@@ -77,13 +77,6 @@ public class LoadingBar {
}
private void setEndTime(LocalTime endTime) {
this.endTime = endTime;
this.totalMinutes = startTime.until(endTime, ChronoUnit.MINUTES);
this.totalMinutesBD = BigDecimal.valueOf(totalMinutes);
}
public static void main(String[] args) throws IOException {
if (args.length == 0) {
askParametersAndRun();
@@ -330,6 +323,19 @@ public class LoadingBar {
}
protected long getPassedMinutes() {
return startTime.until(LocalTime.now().truncatedTo(ChronoUnit.MINUTES), ChronoUnit.MINUTES);
}
private void setEndTime(LocalTime endTime) {
this.endTime = endTime;
this.totalMinutes = startTime.until(endTime, ChronoUnit.MINUTES);
this.totalMinutesBD = BigDecimal.valueOf(totalMinutes);
}
private boolean hasMittagspauseArrived() {
return startTime.until(LocalTime.now(), ChronoUnit.MINUTES) < DEFAULT_NUMBER_WORK_MINS_BEFORE_LUNCH;
}
@@ -393,8 +399,7 @@ public class LoadingBar {
return MIN_LUNCH_DURATION;
}
long totalDuration = MAX_NUMBER_WORK_MINS + endTimeOffset;
long effectiveLunchDuration = totalDuration - MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH;
return getMinLunchDuration(effectiveLunchDuration);
return getMinLunchDuration(totalDuration);
}
@@ -403,12 +408,12 @@ public class LoadingBar {
return MIN_LUNCH_DURATION;
}
long totalDuration = startTime.until(manualEndTime, ChronoUnit.MINUTES);
long effectiveLunchDuration = totalDuration - MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH;
return getMinLunchDuration(effectiveLunchDuration);
return getMinLunchDuration(totalDuration);
}
private long getMinLunchDuration(long effectiveLunchDuration) {
private long getMinLunchDuration(long precalculatedTotalDuration) {
long effectiveLunchDuration = precalculatedTotalDuration - MAX_NUMBER_WORK_MINS_WITHOUT_LUNCH;
if (effectiveLunchDuration < 0) {
effectiveLunchDuration = 0;
}
@@ -431,7 +436,7 @@ public class LoadingBar {
private void showLoadingBar() {
long passedMinutes = startTime.until(LocalTime.now().truncatedTo(ChronoUnit.MINUTES), ChronoUnit.MINUTES);
long passedMinutes = getPassedMinutes();
// long passedMinutes = 0; // DEBUG
if (passedMinutes > totalMinutes) {
passedMinutes = totalMinutes;