diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java index fac0c3e..daa42ad 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java @@ -41,7 +41,6 @@ public class Axel { form+=command.charAt(i); } } - spr.put(cell, form); }while(true); diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java index 961b416..471104a 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java @@ -74,10 +74,9 @@ public class Spreadsheet { return cellName.charAt(1) - '1'; }else { int Row = 0; - Row +=((cellName.charAt(1)-48)*10); - Row +=(cellName.charAt(2)-49); - System.out.println(Row); - return Row; + Row +=((cellName.charAt(1)-'0')*10); + Row +=(cellName.charAt(2)-'0'); + return Row-1; } } // ----- @@ -128,11 +127,23 @@ public class Spreadsheet { private void evaluateCell(int row, int col) { String formula = cells[row][col].getFormula(); String result = ""; - + int offset = 0; + int offsetEnd = 0; + int diff=0; + for(int i = 0; i Standardabweichung @@ -162,12 +173,35 @@ public class Spreadsheet { long res = 0; for(int j = getRow(startCellName); j< (getRow(endCellName)+1);j++){ for(int i = getCol(startCellName); i< (getCol(endCellName)+1);i++) { - if(!cells[j][i].getValue().isBlank()) + if(!cells[j][i].getValue().isBlank()) { res += Long.parseLong(cells[j][i].getValue()); + } } } return res; } + /** + * 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 prod(String startCellName, String endCellName) { + long res = 1; + boolean anyNumbers= false; + for(int j = getRow(startCellName); j< (getRow(endCellName)+1);j++){ + for(int i = getCol(startCellName); i< (getCol(endCellName)+1);i++) { + if(!cells[j][i].getValue().isBlank()) { + res*= Long.parseLong(cells[j][i].getValue()); + anyNumbers = true; + } + } + } + if(anyNumbers) + return res; + else + return 0; + } /** * This method calculates the result of a "normal" algebraic expression. It only needs to support @@ -197,7 +231,6 @@ public class Spreadsheet { } for(int i = 2; i