From e5ada63b88a195212cc040282ec1ff805650e9bf Mon Sep 17 00:00:00 2001 From: devra Date: Mon, 8 Jan 2024 22:48:15 +0100 Subject: [PATCH] =?UTF-8?q?Javadoc-kommentare=20vervollst=C3=A4ndigt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Axel/resources/summe.csv | 2 +- .../informatik/spreadsheet/Spreadsheet.java | 67 ++++++++++++------- 2 files changed, 44 insertions(+), 25 deletions(-) diff --git a/Axel/resources/summe.csv b/Axel/resources/summe.csv index 50d75e1..5dc9d19 100644 --- a/Axel/resources/summe.csv +++ b/Axel/resources/summe.csv @@ -1,4 +1,4 @@ -=SUMME(C1:E2),,=1,=2,=3,,,,, +=SUMME(C1:E2),=MAX(E2:C1),=1,=2,=3,,,,, ,,=4,=5,=6,,,,, ,,,,=0,,,,, ,,,,=0,,,,, diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java index 6abb43a..cff1f6c 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java @@ -153,7 +153,6 @@ public class Spreadsheet { result = "" + sum(onlyCells[0], onlyCells[1]); } } - else if (formula.startsWith("PRODUKT(")) {// e.g. PRODUKT(A3:B9) String[] onlyCells = formula.substring(8, formula.length() - 1).split(":"); @@ -161,9 +160,6 @@ public class Spreadsheet { result = "" + pro(onlyCells[0], onlyCells[1]); } } - - - else if (formula.startsWith("MITTEL(")) { // e.g. MITTEL(A3:A5) String[] onlyCells = formula.substring(7, formula.length() - 1).split(":"); @@ -171,9 +167,6 @@ public class Spreadsheet { result = "" + mit(onlyCells[0], onlyCells[1]); } } - - - else if (formula.startsWith("STABW(")) { // e.g. STABW(C6:D8) -> minimal-wert String[] onlyCells = formula.substring(6, formula.length() - 1).split(":"); @@ -182,25 +175,18 @@ public class Spreadsheet { } } - else if (formula.startsWith("MIN(")) { String[] onlyCells = formula.substring(4, formula.length() - 1).split(":"); if(checkIfCellExists(onlyCells[0])&&checkIfCellExists(onlyCells[1])) { result = "" + min(onlyCells[0], onlyCells[1]); } - - } - - - else if (formula.startsWith("MAX(")) {// e.g. MAX(A1:A10) -> maximal-wert String[] onlyCells = formula.substring(4, formula.length() - 1).split(":"); if(checkIfCellExists(onlyCells[0])&&checkIfCellExists(onlyCells[1])) { result = "" + max(onlyCells[0], onlyCells[1]); } } - else if (!formula.isEmpty()) { try { result = "" + calculate(formula); //calculates the result of a "normal" algebraic expression. @@ -236,7 +222,12 @@ public class Spreadsheet { return summe; } -// TODO: Javadoc comments + /** + * Method for calculating the product of a rectangular block of cells, such as from A1 to B3. + * @param startCellName The name of the cell in the upper left corner of the rectangle. + * @param endCellName The name of the cell in the lower right corner of the rectangle. + * @return The product calculated. + */ private long pro(String startCellName, String endCellName) { int werte[]=getValues(startCellName,endCellName); @@ -247,7 +238,12 @@ public class Spreadsheet { return produkt; } -// TODO: Javadoc comments + /** + * Method for calculating the average of a rectangular block of cells, such as from A1 to B3. + * @param startCellName The name of the cell in the upper left corner of the rectangle. + * @param endCellName The name of the cell in the lower right corner of the rectangle. + * @return The average calculated. + */ private long mit(String startCellName, String endCellName) { int werte[]=getValues(startCellName,endCellName); @@ -256,10 +252,14 @@ public class Spreadsheet { summe+=werte[i]; } return summe/werte.length; - } -// TODO: Javadoc comments + /** + * Method for calculating the standard deviation of a rectangular block of cells, such as from A1 to B3. + * @param startCellName The name of the cell in the upper left corner of the rectangle. + * @param endCellName The name of the cell in the lower right corner of the rectangle. + * @return The standard deviation calculated. + */ private double statbw(String startCellName, String endCellName) { int werte[]=getValues(startCellName,endCellName); @@ -286,7 +286,12 @@ public class Spreadsheet { - + /** + * Method for calculating the minimum-value of a rectangular block of cells, such as from A1 to B3. + * @param startCellName The name of the cell in the upper left corner of the rectangle. + * @param endCellName The name of the cell in the lower right corner of the rectangle. + * @return The minimum-value calculated. + */ private long min(String startCellName, String endCellName) { int werte[]=getValues(startCellName,endCellName); @@ -305,7 +310,12 @@ public class Spreadsheet { } - + /** + * Method for calculating the maximum-value of a rectangular block of cells, such as from A1 to B3. + * @param startCellName The name of the cell in the upper left corner of the rectangle. + * @param endCellName The name of the cell in the lower right corner of the rectangle. + * @return The maximum-value calculated. + */ private long max(String startCellName, String endCellName) { int werte[]=getValues(startCellName,endCellName); @@ -324,7 +334,13 @@ public class Spreadsheet { } -// TODO: Javadoc comments + /** + * Method for reading and saving the values of a rectangular block of cells, such as from A1 to B3. + * @param startCellName The name of the cell in the upper left corner of the rectangle. + * @param endCellName The name of the cell in the lower right corner of the rectangle. + * @return The values that are read, saved in an int array. + */ + private int[] getValues(String startCellName, String endCellName) { int startZeile=getRow(startCellName); int startSpalte=getCol(startCellName); @@ -349,10 +365,9 @@ public class Spreadsheet { } } } - - return werte; } + /** * This method calculates the result of a "normal" algebraic expression. It only needs to support * expressions like =B4 or =2+A3-B2, i.e. only with int numbers and other cells and with plus, @@ -440,7 +455,11 @@ public class Spreadsheet { } - //TODO: Javadoc Comment!! + /** + * Method for checking if a given cell exists inside the current spreadsheet + * @param cellName The name of the cell that is suppsoed to be checked. + * @return true if cell exists inside spreadsheet. + */ public boolean checkIfCellExists(String cellName) { if((getRow(cellName)+1)<=cells.length&&(getCol(cellName)+1)<=cells[0].length) { return true;