diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..c70d51a --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..22c89be --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + PR1-Spreadsheet + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java index d1538e5..c5ad4e9 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java @@ -68,10 +68,7 @@ public class Spreadsheet { } private int getRow(String cellName) { - if(cellName.length()==3) - return Integer.parseInt((cellName.charAt(1)+"")+(cellName.charAt(2)+""))-1; - else - return cellName.charAt(1) - '1'; + return Integer.parseInt(cellName.substring(1))-1; } // ----- @@ -164,18 +161,8 @@ public class Spreadsheet { */ private long sum(String startCellName, String endCellName) { int sum=0; - int startCellRow; - int endCellRow; - if(startCellName.length()==3) - startCellRow=Integer.parseInt((startCellName.charAt(1)+"")+(startCellName.charAt(2)+""))-1; - else - startCellRow=startCellName.charAt(1)-'1'; - if(endCellName.length()==3) - endCellRow=Integer.parseInt((endCellName.charAt(1)+"")+(endCellName.charAt(2)+""))-1; - else - endCellRow=endCellName.charAt(1)-'1'; for(int i=startCellName.charAt(0)-'A'; i<=endCellName.charAt(0)-'A'; i++) { - for(int j=startCellRow; j<=endCellRow; j++) { + for(int j=Integer.parseInt(startCellName.substring(1))-1; j<=Integer.parseInt(endCellName.substring(1))-1; j++) { if(cells[j][i].isEmpty()) { continue; } @@ -186,18 +173,8 @@ public class Spreadsheet { } private long product(String startCellName, String endCellName) { int product=1; - int startCellRow; - int endCellRow; - if(startCellName.length()==3) - startCellRow=Integer.parseInt((startCellName.charAt(1)+"")+(startCellName.charAt(2)+""))-1; - else - startCellRow=startCellName.charAt(1)-'1'; - if(endCellName.length()==3) - endCellRow=Integer.parseInt((endCellName.charAt(1)+"")+(endCellName.charAt(2)+""))-1; - else - endCellRow=endCellName.charAt(1)-'1'; for(int i=startCellName.charAt(0)-'A'; i<=endCellName.charAt(0)-'A'; i++) { - for(int j=startCellRow; j<=endCellRow; j++) { + for(int j=Integer.parseInt(startCellName.substring(1))-1; j<=Integer.parseInt(endCellName.substring(1))-1; j++) { if(cells[j][i].isEmpty()) { return 0; }