From 33f60b0b8b870bb349699db626774f01604cf0ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20H=C3=B6rner?= <3012330@stud.hs-mannheim.de> Date: Tue, 9 Jan 2024 13:02:31 +0100 Subject: [PATCH] ganz kleiner bug in pro gefixxt --- .../informatik/spreadsheet/Spreadsheet.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java index a458548..9274d7c 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java @@ -194,7 +194,7 @@ public class Spreadsheet { String result = ""; if (formula.startsWith("SUMME(")) // e.g. SUMME(A3:A8) - result = "" + sum(formula.substring(6, 8), formula.substring(9, 11)); // TODO adapt to cells with two digits + result = "" + sum(formula.substring(6, 8), formula.substring(9, 11)); // adapt to cells with two digits else if (formula.startsWith("PRODUKT(")) // e.g. PRODUKT(A3:B9) result = "" + pro(formula.substring(8, 10), formula.substring(11, 13)); else if (formula.startsWith("MITTELWERT(")) // e.g. MITTELWERT(A3:A5) @@ -292,15 +292,11 @@ public class Spreadsheet { int endCellRow = getRow(endCellName); int endCellCol = getCol(endCellName); - long res = 0; + long res = 1; for (int i = startCellRow; i <= endCellRow; i++) { for (int j = startCellCol; j <= endCellCol; j++) { - if (res == 0) { - res = Integer.parseInt(cells[i][j].getValue()); - } else { - res = res * (Integer.parseInt(cells[i][j].getValue())); - } + res = res * (Integer.parseInt(cells[i][j].getValue())); } } @@ -411,7 +407,7 @@ public class Spreadsheet { while (m.find()) { // m.find() must always be used before m.group() String s = m.group(); if (!s.isEmpty()) { - System.out.println(s); + //System.out.println(s); zaehler++; switch (zaehler){