removed clutter
This commit is contained in:
@@ -28,24 +28,16 @@ public class DrinkingBar {
|
|||||||
System.out.print("Ankunftszeit: ");
|
System.out.print("Ankunftszeit: ");
|
||||||
var startTime = LocalTime.parse(br.readLine(), TIME_FORMATTER).truncatedTo(ChronoUnit.MINUTES);
|
var startTime = LocalTime.parse(br.readLine(), TIME_FORMATTER).truncatedTo(ChronoUnit.MINUTES);
|
||||||
|
|
||||||
|
|
||||||
long totalMinutes = 8 * MINS_PER_HOUR + MINS_PER_HALF_HOUR;
|
long totalMinutes = 8 * MINS_PER_HOUR + MINS_PER_HALF_HOUR;
|
||||||
long passedMinutes = startTime.until(LocalTime.now().truncatedTo(ChronoUnit.MINUTES), ChronoUnit.MINUTES);
|
long passedMinutes = startTime.until(LocalTime.now().truncatedTo(ChronoUnit.MINUTES), ChronoUnit.MINUTES);
|
||||||
// long passedMinutes = 0; // DEBUG
|
// long passedMinutes = 0; // DEBUG
|
||||||
boolean firstPrint = true;
|
|
||||||
double prevPrintedLitres = 0.0;
|
double prevPrintedLitres = 0.0;
|
||||||
while (passedMinutes < totalMinutes) {
|
while (passedMinutes < totalMinutes) {
|
||||||
if (passedMinutes <= MINUTES_BEFORE_PAUSE || passedMinutes > MINUTES_WITH_PAUSE) {
|
if (passedMinutes <= MINUTES_BEFORE_PAUSE || passedMinutes > MINUTES_WITH_PAUSE) {
|
||||||
double currentLitres = 2.0 / totalMinutes * passedMinutes;
|
double currentLitres = 2.0 / totalMinutes * passedMinutes;
|
||||||
double printedLitres = currentLitres - (currentLitres % 0.25) + 0.25;
|
double printedLitres = currentLitres - (currentLitres % 0.25);
|
||||||
String cursorReset = firstPrint ? "" : "\r";
|
System.out.print("\rAktuelles Volumen: " + LITER_FORMAT.format(printedLitres) + "L");
|
||||||
if (firstPrint || printedLitres - prevPrintedLitres == 0.25) {
|
|
||||||
System.out.print(cursorReset + "Aktuelles Volumen: " + LITER_FORMAT.format(printedLitres) + "L");
|
|
||||||
}
|
|
||||||
prevPrintedLitres = printedLitres;
|
prevPrintedLitres = printedLitres;
|
||||||
if (firstPrint) {
|
|
||||||
firstPrint = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var now = LocalTime.now();
|
var now = LocalTime.now();
|
||||||
|
Reference in New Issue
Block a user