From 8a9fe270b1f08341b794ca29c4fd3f5947a8d875 Mon Sep 17 00:00:00 2001 From: selim Date: Wed, 27 Dec 2023 04:06:50 +0100 Subject: [PATCH] Spreadsheet new uiMethod cellInput implemented. --- .../informatik/spreadsheet/Axel.java | 4 --- .../informatik/spreadsheet/Spreadsheet.java | 26 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java index fb7971b..652fac5 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Axel.java @@ -16,10 +16,6 @@ public class Axel { while (true) { - - spr.cells[sc.nextInt()-1][5].setFormula(sc.next()); - spr.updateSpreadsheet(); - System.out.println(spr.toStringShowFormula()); System.out.println(spr); diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java index 256189b..6f2a3a7 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java @@ -443,6 +443,32 @@ public class Spreadsheet { for (int c = 0; c < cells[r].length; c++) evaluateCell(r, c); } + public void cellInput() throws FileNotFoundException { + Scanner cs = new Scanner(System.in); + + String input = cs.nextLine(); + ArrayList inputs = new ArrayList<>(); + inputs.add(input.split(" ")[0]); + inputs.add(input.split(" ")[1]); + + try { + if (inputs.contains("EINLESEN")) + readCsv(inputs.get(1).split(" ")[0], inputs.get(1).split(" ")[1].charAt(0), inputs.get(1).split(" ")[2]); + else if (inputs.contains("SPEICHERN")) + saveCsv(inputs.get(1)); + else if (inputs.contains("FORMELN")) + System.out.println(toStringShowFormula()); + else + cells[getRow(inputs.get(0)) - 1][getCol(inputs.get(1)) - 1].setFormula(cs.next()); + + updateSpreadsheet(); + } catch(ArrayIndexOutOfBoundsException a){ + System.out.println("\nEingegebene Zelle existiert nicht!"); + } + + inputs.clear(); + + } public String toString() { StringBuilder sb = new StringBuilder();