diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java index df720b3..21f65d8 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java @@ -1,6 +1,7 @@ package de.hs_mannheim.informatik.spreadsheet; import java.io.FileNotFoundException; +import java.util.Scanner; /** * Part of a simplified spreadsheet system for the PR1 programming lab at Hochschule Mannheim. @@ -11,16 +12,32 @@ public class Axel { public static void main(String[] args) throws FileNotFoundException { Spreadsheet spr = new Spreadsheet(10,10); + String cell, in; + Scanner kb = new Scanner(System.in); - spr.put("A3", "123"); + spr.put("A3", "3"); spr.put("A2", "1"); spr.put("B9", "=41+A2"); spr.put("J5", "=7*6"); spr.put("J6", "=3/2"); - System.out.println(spr); - + while(true) { + System.out.println(spr); + System.out.print("Cell:"); + cell=kb.nextLine(); + if(cell.equals("/exit")) { + System.out.println("Auf Wiedersehen"); + break; + } + System.out.print("Value:"); + in=kb.nextLine(); + if(in.equals("/exit")) { + System.out.println("Auf Wiedersehen"); + break; + } + spr.put(cell,in); + } spr.saveCsv("/tmp/test.csv"); // 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..4333146 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java @@ -21,9 +21,15 @@ public class Spreadsheet { * @param cols number of columns */ public Spreadsheet(int rows, int cols) { - + // TODO limit the maximum size on 99 (1..99) rows and 26 (A..Z) columns - + if (rows>99){ + rows=99; + } + if (cols>26) { + cols=26; + } + cells = new Cell[rows][cols]; for (int r = 0; r < rows; r++) @@ -182,7 +188,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++) { sb.append(" " + (char)('A'+ i) + " | "); }