Compare commits
14 Commits
d87e503cfe
...
f0bda09710
Author | SHA1 | Date | |
---|---|---|---|
f0bda09710 | |||
1f1e06a8e1 | |||
1e40a19b69 | |||
45bee2714b | |||
971bf22495 | |||
e6ef9ec87f | |||
7fc7efd166 | |||
23d73ee19d | |||
853beb07d2 | |||
e88c1a3d49 | |||
d0687c9568 | |||
d9553ace7a | |||
f8e1b13ae5 | |||
f5474a59fa |
@@ -19,7 +19,10 @@ public class DrinkingBar {
|
||||
private static final int MINUTES_BEFORE_PAUSE = 4 * MINS_PER_HOUR + MINS_PER_HALF_HOUR;
|
||||
private static final int MINUTES_WITH_PAUSE = 6 * MINS_PER_HOUR;
|
||||
private static final int DEFAULT_TOTAL_TIME = 8 * MINS_PER_HOUR + MINS_PER_HALF_HOUR;
|
||||
private static final DecimalFormat LITER_FORMAT = new DecimalFormat("0.00");
|
||||
private static final BigDecimal DEFAULT_TOTAL_TIME_BD = BigDecimal.valueOf(DEFAULT_TOTAL_TIME);
|
||||
private static final BigDecimal DEFAULT_TOTAL_LITRES = BigDecimal.valueOf(2.0);
|
||||
private static final BigDecimal QUARTER_LITRE = BigDecimal.valueOf(0.25);
|
||||
private static final DecimalFormat LITRE_FORMAT = new DecimalFormat("0.00");
|
||||
private static final DecimalFormat PERCENTAGE_FORMAT = new DecimalFormat("00.00");
|
||||
private static final BigDecimal MINS_PER_HOUR_BD = BigDecimal.valueOf(MINS_PER_HOUR);
|
||||
private static final MathContext MC_INTEGER = new MathContext(1, RoundingMode.HALF_EVEN);
|
||||
@@ -28,6 +31,7 @@ public class DrinkingBar {
|
||||
private LocalTime endTime;
|
||||
private long totalMinutes;
|
||||
private BigDecimal totalMinutesBD;
|
||||
private BigDecimal totalLitres;
|
||||
|
||||
|
||||
private DrinkingBar(LocalTime startTime) {
|
||||
@@ -35,6 +39,7 @@ public class DrinkingBar {
|
||||
this.totalMinutes = DEFAULT_TOTAL_TIME;
|
||||
this.totalMinutesBD = BigDecimal.valueOf(totalMinutes);
|
||||
this.endTime = startTime.plusMinutes(totalMinutes);
|
||||
this.totalLitres = DEFAULT_TOTAL_LITRES;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,15 +62,36 @@ public class DrinkingBar {
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
extraInitEndTimeTotalMinutes();
|
||||
}
|
||||
|
||||
|
||||
protected void extraInitEndTimeTotalMinutes() {
|
||||
// correct necessary litres to drink based on the end time.
|
||||
// lower the volume in quarter litre steps
|
||||
BigDecimal calcTotalLitres = DEFAULT_TOTAL_LITRES;
|
||||
BigDecimal totalLitresFromMinutes = DEFAULT_TOTAL_LITRES
|
||||
.multiply(totalMinutesBD) // reverse dreisatz
|
||||
.divide(DEFAULT_TOTAL_TIME_BD, MathContext.DECIMAL64);
|
||||
do {
|
||||
calcTotalLitres = calcTotalLitres.subtract(QUARTER_LITRE);
|
||||
} while (calcTotalLitres.compareTo(totalLitresFromMinutes) >= 0);
|
||||
// add quarter since we always did a step "too many", due to the do ... while loop
|
||||
this.totalLitres = calcTotalLitres.add(QUARTER_LITRE);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@@ -84,28 +110,34 @@ public class DrinkingBar {
|
||||
|
||||
|
||||
private String fillLoadingBar(long passedMinutes, boolean progressive) {
|
||||
long effectivePassedMinutes = passedMinutes;
|
||||
if (passedMinutes > MINUTES_BEFORE_PAUSE && passedMinutes <= MINUTES_WITH_PAUSE) {
|
||||
long effectivePassedMinutes = passedMinutes < 0 ? 0 : passedMinutes;
|
||||
if (totalMinutes > MINUTES_WITH_PAUSE && passedMinutes > MINUTES_BEFORE_PAUSE && passedMinutes <= MINUTES_WITH_PAUSE) {
|
||||
effectivePassedMinutes = MINUTES_BEFORE_PAUSE;
|
||||
}
|
||||
double currentLitres = 2.0 / totalMinutes * effectivePassedMinutes + 0.25;
|
||||
double printedLitres = currentLitres - (currentLitres % 0.25);
|
||||
// double currentProgressToNextStep = 100 / 0.25 * (currentLitres - printedLitres);
|
||||
var effectivePassedMinutesBD = BigDecimal.valueOf(effectivePassedMinutes);
|
||||
BigDecimal currentLitres = totalLitres
|
||||
.multiply(effectivePassedMinutesBD) // reverse dreisatz
|
||||
.divide(totalMinutesBD, MathContext.DECIMAL64)
|
||||
.add(QUARTER_LITRE);
|
||||
BigDecimal printedLitres = currentLitres.subtract(currentLitres.remainder(QUARTER_LITRE, MathContext.DECIMAL64));
|
||||
/* BigDecimal currentProgressToNextStep = ONE_HUNDRED_PERCENT
|
||||
.multiply(currentLitres.subtract(printedLitres)) // reverse dreisatz
|
||||
.divide(QUARTER_LITRE, MathContext.DECIMAL64); */
|
||||
BigDecimal minutesToNextStep = getMinutesToNextStep(currentLitres);
|
||||
String progressivePart = progressive ? "\r" : "";
|
||||
return progressivePart + "Aktuelles Volumen: " + LITER_FORMAT.format(printedLitres) + "L - "
|
||||
return progressivePart + "Aktuelles Volumen: " + LITRE_FORMAT.format(printedLitres) + "L - "
|
||||
// + PERCENTAGE_FORMAT.format(currentProgressToNextStep) + "% - "
|
||||
+ minutesToTimeString(minutesToNextStep);
|
||||
}
|
||||
|
||||
|
||||
private BigDecimal getMinutesToNextStep(double currentLitres) {
|
||||
private BigDecimal getMinutesToNextStep(BigDecimal currentLitres) {
|
||||
// berechne Liter benötigt bis zum nächsten 0.25er Schritt
|
||||
double litresToNextStep = 0.25 - (currentLitres % 0.25);
|
||||
BigDecimal litresToNextStep = QUARTER_LITRE.subtract(currentLitres.remainder(QUARTER_LITRE));
|
||||
// berechne Minuten benötigt für 1 Liter
|
||||
double minutesPerLitre = totalMinutes / 2.0;
|
||||
BigDecimal minutesPerLitre = totalMinutesBD.divide(totalLitres, MathContext.DECIMAL64);
|
||||
// berechne Minuten benötigt bis zum nächsten 0.25er Schritt
|
||||
return BigDecimal.valueOf((minutesPerLitre * litresToNextStep) + 1);
|
||||
return minutesPerLitre.multiply(litresToNextStep).setScale(0, RoundingMode.HALF_EVEN);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -112,6 +112,11 @@ public class SimpleLoadingBar {
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@@ -128,7 +133,7 @@ public class SimpleLoadingBar {
|
||||
|
||||
|
||||
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;
|
||||
|
@@ -1,3 +1,3 @@
|
||||
#/usr/bin/env bash
|
||||
|
||||
javac -p target/ src/**/*.java
|
||||
javac -d target/ src/**/*.java
|
||||
|
@@ -31,9 +31,7 @@ public abstract class AbstractLoadingBar {
|
||||
|
||||
protected AbstractLoadingBar(LocalTime startTime, long totalMinutes) {
|
||||
this.startTime = startTime;
|
||||
this.endTime = startTime.plusMinutes(totalMinutes);
|
||||
this.totalMinutes = totalMinutes;
|
||||
this.totalMinutesBD = BigDecimal.valueOf(totalMinutes);
|
||||
setTotalMinutes(totalMinutes);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,23 +45,45 @@ public abstract class AbstractLoadingBar {
|
||||
}
|
||||
|
||||
|
||||
protected void setEndTime(LocalTime endTime) {
|
||||
protected final void setEndTime(LocalTime endTime) {
|
||||
this.endTime = endTime;
|
||||
this.totalMinutes = startTime.until(endTime, ChronoUnit.MINUTES);
|
||||
this.totalMinutesBD = BigDecimal.valueOf(totalMinutes);
|
||||
extraInitEndTimeTotalMinutes();
|
||||
}
|
||||
|
||||
|
||||
protected void extraInitEndTimeTotalMinutes() {}
|
||||
|
||||
|
||||
protected long getTotalMinutes() {
|
||||
return totalMinutes;
|
||||
}
|
||||
|
||||
|
||||
protected final void setTotalMinutes(long totalMinutes) {
|
||||
this.totalMinutes = totalMinutes;
|
||||
this.totalMinutesBD = BigDecimal.valueOf(totalMinutes);
|
||||
this.endTime = startTime.plusMinutes(totalMinutes);
|
||||
extraInitEndTimeTotalMinutes();
|
||||
}
|
||||
|
||||
|
||||
protected BigDecimal getTotalMinutesBD() {
|
||||
return totalMinutesBD;
|
||||
}
|
||||
|
||||
|
||||
protected long getPassedMinutes() {
|
||||
return getPassedMinutes(false);
|
||||
}
|
||||
|
||||
|
||||
protected long getPassedMinutes(boolean passedMinutesZero) {
|
||||
return passedMinutesZero ? 0 : startTime.until(LocalTime.now().truncatedTo(ChronoUnit.MINUTES), ChronoUnit.MINUTES);
|
||||
}
|
||||
|
||||
|
||||
protected void showLoadingBar() {
|
||||
showLoadingBar(false, false, 0);
|
||||
}
|
||||
@@ -90,10 +110,7 @@ public abstract class AbstractLoadingBar {
|
||||
|
||||
|
||||
private void showLoadingBar(boolean debug, boolean passedMinutesZero, long millisWaiting) {
|
||||
long passedMinutes = startTime.until(LocalTime.now().truncatedTo(ChronoUnit.MINUTES), ChronoUnit.MINUTES);
|
||||
if (debug && passedMinutesZero) {
|
||||
passedMinutes = 0;
|
||||
}
|
||||
long passedMinutes = getPassedMinutes(debug && passedMinutesZero);
|
||||
if (passedMinutes > totalMinutes) {
|
||||
passedMinutes = totalMinutes;
|
||||
} else if (passedMinutes < 0) {
|
||||
|
@@ -6,6 +6,8 @@ import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalTime;
|
||||
@@ -20,12 +22,12 @@ public class DrinkingBar extends AbstractLoadingBar {
|
||||
private static final int MINUTES_BEFORE_PAUSE = 4 * CommonTools.MINS_PER_HOUR + MINS_PER_HALF_HOUR;
|
||||
private static final int MINUTES_WITH_PAUSE = 6 * CommonTools.MINS_PER_HOUR;
|
||||
private static final int DEFAULT_TOTAL_TIME = 8 * CommonTools.MINS_PER_HOUR + MINS_PER_HALF_HOUR;
|
||||
private static final DecimalFormat LITER_FORMAT = new DecimalFormat("0.00");
|
||||
private static final BigDecimal DEFAULT_TOTAL_TIME_BD = BigDecimal.valueOf(DEFAULT_TOTAL_TIME);
|
||||
private static final BigDecimal DEFAULT_TOTAL_LITRES = BigDecimal.valueOf(2.0);
|
||||
private static final BigDecimal QUARTER_LITRE = BigDecimal.valueOf(0.25);
|
||||
private static final DecimalFormat LITRE_FORMAT = new DecimalFormat("0.00");
|
||||
|
||||
|
||||
protected DrinkingBar(LocalTime startTime) {
|
||||
super(startTime, DEFAULT_TOTAL_TIME);
|
||||
}
|
||||
private BigDecimal totalLitres;
|
||||
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
@@ -37,29 +39,57 @@ public class DrinkingBar extends AbstractLoadingBar {
|
||||
}
|
||||
|
||||
|
||||
protected DrinkingBar(LocalTime startTime) {
|
||||
super(startTime, DEFAULT_TOTAL_TIME);
|
||||
this.totalLitres = DEFAULT_TOTAL_LITRES;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void extraInitEndTimeTotalMinutes() {
|
||||
// correct necessary litres to drink based on the end time.
|
||||
// lower the volume in quarter litre steps
|
||||
BigDecimal calcTotalLitres = DEFAULT_TOTAL_LITRES;
|
||||
BigDecimal totalLitresFromMinutes = DEFAULT_TOTAL_LITRES
|
||||
.multiply(getTotalMinutesBD()) // reverse dreisatz
|
||||
.divide(DEFAULT_TOTAL_TIME_BD, MathContext.DECIMAL64);
|
||||
do {
|
||||
calcTotalLitres = calcTotalLitres.subtract(QUARTER_LITRE);
|
||||
} while (calcTotalLitres.compareTo(totalLitresFromMinutes) >= 0);
|
||||
// add quarter since we always did a step "too many", due to the do ... while loop
|
||||
this.totalLitres = calcTotalLitres.add(QUARTER_LITRE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String fillLoadingBar(long passedMinutes, boolean progressive) {
|
||||
long effectivePassedMinutes = passedMinutes;
|
||||
if (passedMinutes > MINUTES_BEFORE_PAUSE && passedMinutes <= MINUTES_WITH_PAUSE) {
|
||||
long effectivePassedMinutes = passedMinutes < 0 ? 0 : passedMinutes;
|
||||
if (getTotalMinutes() > MINUTES_WITH_PAUSE && passedMinutes > MINUTES_BEFORE_PAUSE && passedMinutes <= MINUTES_WITH_PAUSE) {
|
||||
effectivePassedMinutes = MINUTES_BEFORE_PAUSE;
|
||||
}
|
||||
double currentLitres = 2.0 / getTotalMinutes() * effectivePassedMinutes + 0.25;
|
||||
double printedLitres = currentLitres - (currentLitres % 0.25);
|
||||
// double currentProgressToNextStep = 100 / 0.25 * (currentLitres - printedLitres);
|
||||
var effectivePassedMinutesBD = BigDecimal.valueOf(effectivePassedMinutes);
|
||||
BigDecimal currentLitres = totalLitres
|
||||
.multiply(effectivePassedMinutesBD) // reverse dreisatz
|
||||
.divide(getTotalMinutesBD(), MathContext.DECIMAL64)
|
||||
.add(QUARTER_LITRE);
|
||||
BigDecimal printedLitres = currentLitres.subtract(currentLitres.remainder(QUARTER_LITRE, MathContext.DECIMAL64));
|
||||
/* BigDecimal currentProgressToNextStep = ONE_HUNDRED_PERCENT
|
||||
.multiply(currentLitres.subtract(printedLitres)) // reverse dreisatz
|
||||
.divide(QUARTER_LITRE, MathContext.DECIMAL64); */
|
||||
BigDecimal minutesToNextStep = getMinutesToNextStep(currentLitres);
|
||||
String progressivePart = progressive ? "\r" : "";
|
||||
return progressivePart + "Aktuelles Volumen: " + LITER_FORMAT.format(printedLitres) + "L - "
|
||||
return progressivePart + "Aktuelles Volumen: " + LITRE_FORMAT.format(printedLitres) + "L - "
|
||||
// + FormatTools.PERCENTAGE_FORMAT.format(currentProgressToNextStep) + "% - "
|
||||
+ FormatTools.minutesToTimeString(minutesToNextStep);
|
||||
}
|
||||
|
||||
|
||||
private BigDecimal getMinutesToNextStep(double currentLitres) {
|
||||
private BigDecimal getMinutesToNextStep(BigDecimal currentLitres) {
|
||||
// berechne Liter benötigt bis zum nächsten 0.25er Schritt
|
||||
double litresToNextStep = 0.25 - (currentLitres % 0.25);
|
||||
BigDecimal litresToNextStep = QUARTER_LITRE.subtract(currentLitres.remainder(QUARTER_LITRE));
|
||||
// berechne Minuten benötigt für 1 Liter
|
||||
double minutesPerLitre = getTotalMinutes() / 2.0;
|
||||
BigDecimal minutesPerLitre = getTotalMinutesBD().divide(totalLitres, MathContext.DECIMAL64);
|
||||
// berechne Minuten benötigt bis zum nächsten 0.25er Schritt
|
||||
return BigDecimal.valueOf((minutesPerLitre * litresToNextStep) + 1);
|
||||
return minutesPerLitre.multiply(litresToNextStep).setScale(0, RoundingMode.HALF_EVEN);
|
||||
}
|
||||
}
|
||||
|
@@ -76,14 +76,16 @@ public class LoadingBar extends AbstractProgressBar {
|
||||
print("Ankunftszeit: ");
|
||||
var startTime = LocalTime.parse(br.readLine(), FormatTools.TIME_FORMATTER).truncatedTo(ChronoUnit.MINUTES);
|
||||
var lb = new LoadingBar(startTime);
|
||||
// boolean passedMinutesZero = true; // DEBUG
|
||||
if (lb.hasMittagspauseArrived()) {
|
||||
// if (lb.hasMittagspauseArrived(passedMinutesZero)) { // DEBUG
|
||||
handleMittagspause(br, lb);
|
||||
lb.showLoadingBar();
|
||||
// lb.showLoadingBarDebug(); // DEBUG
|
||||
// lb.showLoadingBarDebug(passedMinutesZero); // DEBUG
|
||||
}
|
||||
handleZapfenstreich(br, lb);
|
||||
lb.showLoadingBar();
|
||||
// lb.showLoadingBarDebug(); // DEBUG
|
||||
// lb.showLoadingBarDebug(passedMinutesZero); // DEBUG
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +141,7 @@ public class LoadingBar extends AbstractProgressBar {
|
||||
private static void parseParametersAndRun(String[] args) {
|
||||
LoadingBar lb = getLoadingBarFromCLI(args);
|
||||
lb.showLoadingBar();
|
||||
// lb.showLoadingBarDebug(); // DEBUG
|
||||
// wlb.showLoadingBarDebug(true); // DEBUG
|
||||
}
|
||||
|
||||
|
||||
@@ -302,7 +304,12 @@ public class LoadingBar extends AbstractProgressBar {
|
||||
|
||||
|
||||
protected boolean hasMittagspauseArrived() {
|
||||
return getStartTime().until(LocalTime.now(), ChronoUnit.MINUTES) < DEFAULT_NUMBER_WORK_MINS_BEFORE_LUNCH;
|
||||
return hasMittagspauseArrived(false);
|
||||
}
|
||||
|
||||
|
||||
protected boolean hasMittagspauseArrived(boolean debugWithPassedMinutesZero) {
|
||||
return getPassedMinutes(debugWithPassedMinutesZero) < DEFAULT_NUMBER_WORK_MINS_BEFORE_LUNCH;
|
||||
}
|
||||
|
||||
|
||||
@@ -360,12 +367,11 @@ public class LoadingBar extends AbstractProgressBar {
|
||||
|
||||
|
||||
private long getMinLunchDuration(int endTimeOffset) {
|
||||
if (endTimeOffset == 0) {
|
||||
if (endTimeOffset <= 0) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -374,12 +380,12 @@ public class LoadingBar extends AbstractProgressBar {
|
||||
return MIN_LUNCH_DURATION;
|
||||
}
|
||||
long totalDuration = getStartTime().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;
|
||||
}
|
||||
|
@@ -41,26 +41,28 @@ public class WorkLoadingBar extends AbstractProgressBar {
|
||||
var lb = new LoadingBar(startTime);
|
||||
var db = new DrinkingBar(startTime);
|
||||
var wlb = new WorkLoadingBar(lb, db);
|
||||
// boolean passedMinutesZero = true; // DEBUG
|
||||
if (lb.hasMittagspauseArrived()) {
|
||||
// if (lb.hasMittagspauseArrived(passedMinutesZero)) { // DEBUG
|
||||
handleMittagspause(br, wlb);
|
||||
wlb.showLoadingBar();
|
||||
// wlb.showLoadingBarDebug(); // DEBUG
|
||||
// wlb.showLoadingBarDebug(passedMinutesZero); // DEBUG
|
||||
}
|
||||
handleZapfenstreich(br, wlb);
|
||||
wlb.showLoadingBar();
|
||||
// wlb.showLoadingBarDebug(); // DEBUG
|
||||
// wlb.showLoadingBarDebug(passedMinutesZero); // DEBUG
|
||||
}
|
||||
|
||||
|
||||
private static void handleMittagspause(BufferedReader br, WorkLoadingBar wlb) throws IOException {
|
||||
LoadingBar.handleMittagspause(br, wlb.loadingBar);
|
||||
wlb.setEndTime(wlb.loadingBar.getEndTime(), false);
|
||||
wlb.setEndTime(wlb.loadingBar.getEndTime());
|
||||
}
|
||||
|
||||
|
||||
private static void handleZapfenstreich(BufferedReader br, WorkLoadingBar wlb) throws IOException {
|
||||
LoadingBar.handleZapfenstreich(br, wlb.loadingBar);
|
||||
wlb.setEndTime(wlb.loadingBar.getEndTime(), true);
|
||||
wlb.setEndTime(wlb.loadingBar.getEndTime());
|
||||
}
|
||||
|
||||
|
||||
@@ -68,17 +70,15 @@ public class WorkLoadingBar extends AbstractProgressBar {
|
||||
LoadingBar lb = LoadingBar.getLoadingBarFromCLI(args);
|
||||
var db = new DrinkingBar(lb.getStartTime());
|
||||
var wlb = new WorkLoadingBar(lb, db);
|
||||
wlb.setEndTime(wlb.loadingBar.getEndTime(), true);
|
||||
wlb.setEndTime(wlb.loadingBar.getEndTime());
|
||||
wlb.showLoadingBar();
|
||||
// wlb.showLoadingBarDebug(); // DEBUG
|
||||
// wlb.showLoadingBarDebug(true); // DEBUG
|
||||
}
|
||||
|
||||
|
||||
protected void setEndTime(LocalTime endTime, boolean finalEndTime) {
|
||||
setEndTime(endTime);
|
||||
if (finalEndTime) {
|
||||
drinkingBar.setEndTime(endTime);
|
||||
}
|
||||
@Override
|
||||
protected void extraInitEndTimeTotalMinutes() {
|
||||
drinkingBar.setEndTime(getEndTime());
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user