diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java index 312e2bd..f63556a 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java @@ -69,9 +69,29 @@ public class Spreadsheet { put(getRow(cellName), getCol(cellName), value); } - private int getCol(String cellName) {return cellName.charAt(0) - 'A';} - private int getRow(String cellName) {return cellName.charAt(1) - '1';} + private int getCol(String cellName) { + int merker = 0; + for (int i = 0; i < cellName.length(); i++) { + if (cellName.charAt(i) >= 'A' && cellName.charAt(i) <= 'Z') { + merker = (merker * 10) + (cellName.charAt(i) - ('A'-1)); + } else { + break; + } + } + return merker-1; + } + + + private int getRow(String cellName) { + int merker = 0; + for (int i = 0; i < cellName.length(); i++) { + if (!(cellName.charAt(i) >= 'A' && cellName.charAt(i) <= 'Z')) { + merker = (merker * 10) + (cellName.charAt(i) - '0'); + } + } + return merker-1; + } // ----- // business logic @@ -104,7 +124,7 @@ public class Spreadsheet { else out.print(cell.getValue()); - if (cell != row[cells.length-1]) + if (cell != row[cells[0].length-1]) // "[0]" -> nimmt sonst die falsche Länge! out.print(","); } out.println(); @@ -190,7 +210,7 @@ public class Spreadsheet { StringBuilder sb = new StringBuilder(); sb.append(" "); - for (int i = 0; i < cells.length; i++) { + for (int i = 0; i < cells[0].length; i++) { // "[0]" -> nimmt sonst die falsche Länge! sb.append(" " + (char)('A'+ i) + " | "); }