diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java index 18dcd7a..cd6e2f6 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java @@ -239,9 +239,24 @@ public class Spreadsheet { * @return The minimum value of the block. */ private long min(String startCellName, String endCellName) { + long result = 0; + for(char col = startCellName.charAt(0); col <= endCellName.charAt(0); col++){ - return 0; + for(int row = Integer.parseInt(startCellName.substring(1)); row <= Integer.parseInt(endCellName.substring(1)); row++) { + + String value = get((row - 1), (col - 'A')); //"-1" because we start with 1 instead of 0. "-A" because A in ascii is 65, but we start with 0 + + if((col == startCellName.charAt(0)) && (row == Integer.parseInt(startCellName.substring(1)))) { + result = Long.parseLong(value); + } + else if(!value.isEmpty() && (Long.parseLong(value) < result)){ + result = Long.parseLong(value); + } + } + } + + return result; } /** @@ -251,9 +266,24 @@ public class Spreadsheet { * @return The maximum value of the block. */ private long max(String startCellName, String endCellName) { + long result = 0; + for(char col = startCellName.charAt(0); col <= endCellName.charAt(0); col++){ - return 0; + for(int row = Integer.parseInt(startCellName.substring(1)); row <= Integer.parseInt(endCellName.substring(1)); row++) { + + String value = get((row - 1), (col - 'A')); //"-1" because we start with 1 instead of 0. "-A" because A in ascii is 65, but we start with 0 + + if((col == startCellName.charAt(0)) && (row == Integer.parseInt(startCellName.substring(1)))) { + result = Long.parseLong(value); + } + else if(!value.isEmpty() && (Long.parseLong(value) > result)){ + result = Long.parseLong(value); + } + } + } + + return result; }