improve readability

This commit is contained in:
2025-07-22 09:21:47 +02:00
parent 7cab32467d
commit d73f2e0cd4

View File

@@ -77,8 +77,7 @@ public class LoadingBar {
private static void askParametersAndRun() throws IOException { private static void askParametersAndRun() throws IOException {
var br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); var br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
print("Ankunftszeit: "); print("Ankunftszeit: ");
String startTimeRaw = br.readLine(); var startTime = LocalTime.parse(br.readLine(), TIME_FORMATTER).truncatedTo(ChronoUnit.MINUTES);
var startTime = LocalTime.parse(startTimeRaw, TIME_FORMATTER).truncatedTo(ChronoUnit.MINUTES);
handleMittagspause(br, startTime); handleMittagspause(br, startTime);
handleZapfenstreich(br, startTime); handleZapfenstreich(br, startTime);
} }
@@ -422,8 +421,9 @@ public class LoadingBar {
private static String fillLoadingBar(long totalMinutes, long passedMinutes, boolean progressive) { private static String fillLoadingBar(long totalMinutes, long passedMinutes, boolean progressive) {
var nonNegativePassedMinutes = passedMinutes < 0 ? 0 : passedMinutes; var nonNegativePassedMinutes = passedMinutes < 0 ? 0 : passedMinutes;
BigDecimal wholePercentage = BigDecimal.valueOf(100) BigDecimal wholePercentage = BigDecimal.valueOf(100)
.multiply( // kind of reverse dreisatz to avoid to have e.g. 99.9999 instead of 100 % // kind of reverse dreisatz to avoid having e.g. 99.9999 instead of 100 %
BigDecimal.valueOf(nonNegativePassedMinutes).divide(BigDecimal.valueOf(totalMinutes), MathContext.DECIMAL64)); .multiply(BigDecimal.valueOf(nonNegativePassedMinutes))
.divide(BigDecimal.valueOf(totalMinutes), MathContext.DECIMAL64);
int numberOfEquals = wholePercentage.intValue(); int numberOfEquals = wholePercentage.intValue();
var sb = new StringBuilder("["); var sb = new StringBuilder("[");
for (int i = 0; i < LINE_LENGTH; i++) { for (int i = 0; i < LINE_LENGTH; i++) {