diff --git a/Axel/resources/zahlen.csv b/Axel/resources/zahlen.csv index 1ec60e0..0f60336 100644 --- a/Axel/resources/zahlen.csv +++ b/Axel/resources/zahlen.csv @@ -1,4 +1,10 @@ -1,2 -3,4 -5,6 -7,8 +123,,,,,,,,,1111 +1,,,,,,,,, +,,,,,,,,, +,,,,,,,,, +,,,,,,,,,=7*6 +,,,,,,,,,=3/2 +,,,,,,,,, +,,,,,,,,, +,=41+A2,,,,,,,, +,,,,,,,,, diff --git a/Axel/resources/zahlen2.csv b/Axel/resources/zahlen2.csv new file mode 100644 index 0000000..5d304d0 --- /dev/null +++ b/Axel/resources/zahlen2.csv @@ -0,0 +1,10 @@ +,,,,,,,,, +1,,,,,,,,, +123,,,,,,,,, +,,,,,,,,, +,,,,,,,,,=7*6 +,,,,,,,,,=3/2 +,,,,,,,,, +,,,,,,,,, +,=41+A2,,,,,,,, +,,,,,,,,, diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java index df720b3..e844b60 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java @@ -12,16 +12,24 @@ public class Axel { public static void main(String[] args) throws FileNotFoundException { Spreadsheet spr = new Spreadsheet(10,10); - spr.put("A3", "123"); + spr.put("A1", "123"); spr.put("A2", "1"); spr.put("B9", "=41+A2"); spr.put("J5", "=7*6"); spr.put("J6", "=3/2"); + + spr.put("J10", "1111"); // Das Programm konnte keine Zellen mit 2 Stellen (>9) einlesen! (-> Programm macht es an Stelle 1 statt 10) System.out.println(spr); - - spr.saveCsv("/tmp/test.csv"); + + spr.saveCsv("C:\\Users\\flori\\IdeaProjects\\PR1-Spreadsheet\\Axel\\resources\\zahlen.csv"); + + + + //spr.readCsv("C:\\Users\\flori\\IdeaProjects\\PR1-Spreadsheet\\Axel\\resources\\zahlen2.csv", ',',"A1"); + //System.out.println(spr); + // TODO: You might want to put "UI loop" for entering value and formulas here resp. in some UI methods. } diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java index de46be0..312e2bd 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java @@ -24,6 +24,18 @@ public class Spreadsheet { // TODO limit the maximum size on 99 (1..99) rows and 26 (A..Z) columns + if (rows > 99) { + rows = 99; + } else if (rows <= 0) { + rows = 1; + } + + if (cols > 26) { + cols = 26; + } else if (cols <= 0) { + cols = 1; + } + cells = new Cell[rows][cols]; for (int r = 0; r < rows; r++) @@ -57,13 +69,9 @@ public class Spreadsheet { put(getRow(cellName), getCol(cellName), value); } - private int getCol(String cellName) { - return cellName.charAt(0) - 'A'; - } + private int getCol(String cellName) {return cellName.charAt(0) - 'A';} - private int getRow(String cellName) { - return cellName.charAt(1) - '1'; - } + private int getRow(String cellName) {return cellName.charAt(1) - '1';} // ----- // business logic @@ -72,7 +80,7 @@ public class Spreadsheet { * A method for reading in data from a CSV file. * @param path The file to read. * @param separator The char used to split up the input, e.g. a comma or a semicolon. - * @param starCellName The upper left cell where data from the CSV file should be inserted. + * @param startCellName The upper left cell where data from the CSV file should be inserted. * @return Nothing. * @exception IOException If path does not exist. */