2023-12-12 15:00:07 +01:00
|
|
|
package de.hs_mannheim.informatik.spreadsheet;
|
|
|
|
|
2023-12-14 08:31:20 +01:00
|
|
|
import java.io.FileNotFoundException;
|
2024-01-06 15:24:05 +01:00
|
|
|
import java.util.Scanner;
|
2023-12-12 15:00:07 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Part of a simplified spreadsheet system for the PR1 programming lab at Hochschule Mannheim.
|
2024-01-06 22:18:47 +01:00
|
|
|
*
|
2023-12-12 15:00:07 +01:00
|
|
|
* @author Oliver Hummel
|
|
|
|
*/
|
|
|
|
public class Axel {
|
|
|
|
|
2023-12-14 08:31:20 +01:00
|
|
|
public static void main(String[] args) throws FileNotFoundException {
|
2023-12-12 15:00:07 +01:00
|
|
|
Spreadsheet spr = new Spreadsheet(10,10);
|
2024-01-06 15:24:05 +01:00
|
|
|
@SuppressWarnings("resource")
|
|
|
|
Scanner input = new Scanner(System.in);
|
2023-12-12 15:00:07 +01:00
|
|
|
|
|
|
|
spr.put("A3", "123");
|
|
|
|
|
2024-01-06 20:40:58 +01:00
|
|
|
spr.put("B9", "=41+A2+10-2/3");
|
2024-01-07 11:36:28 +01:00
|
|
|
spr.put("B8", "2");
|
|
|
|
spr.put("B7", "20");
|
|
|
|
spr.put("B6", "42");
|
|
|
|
spr.put("B5", "23");
|
|
|
|
spr.put("B4", "24");
|
|
|
|
spr.put("B3", "24");
|
|
|
|
spr.put("B2", "28");
|
|
|
|
spr.put("B1", "24");
|
|
|
|
|
2023-12-12 15:00:07 +01:00
|
|
|
|
2024-01-06 15:24:05 +01:00
|
|
|
System.out.println("Schreibe 'stop' zum anhalten.");
|
|
|
|
do{
|
|
|
|
String command = "";
|
|
|
|
String form = "";
|
|
|
|
String cell= "";
|
2024-01-06 20:40:58 +01:00
|
|
|
boolean cellTRUE = true;
|
2024-01-06 15:24:05 +01:00
|
|
|
System.out.println(spr);
|
|
|
|
System.out.println("Befehl (z.B. D4_=7*6): ");
|
|
|
|
command = input.nextLine();
|
2024-01-07 11:36:28 +01:00
|
|
|
if(command.matches("[A-Za-z][1-9][0-9]?_="
|
|
|
|
+ "((((([A-Za-z][1-9][0-9]?)|([0-9]+))(\\*|\\+|\\-|\\/))*"
|
|
|
|
+ "(([A-Za-z][1-9][0-9]?)|([0-9]+)))|"
|
|
|
|
+ "((SUMME|PRODUKT|MID|STABW|MIN|MAX)\\(([A-Za-z][1-9][0-9]*\\:[A-Za-z][1-9][0-9]*)\\)))")) {
|
2024-01-07 10:36:27 +01:00
|
|
|
for(int i = 0; i<command.length();i++) {
|
|
|
|
if(command.charAt(i)=='_') {
|
|
|
|
cellTRUE = false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if(cellTRUE) {
|
|
|
|
cell+=command.charAt(i);
|
|
|
|
}else {
|
|
|
|
form+=command.charAt(i);
|
|
|
|
}
|
2024-01-06 20:40:58 +01:00
|
|
|
}
|
2024-01-07 10:36:27 +01:00
|
|
|
spr.put(cell, form);
|
|
|
|
}else if(command.matches("stop")){
|
|
|
|
break;
|
|
|
|
}else {
|
|
|
|
System.out.println("Die Eingabe war nicht korrekt. Die Tabelle bleibt auf folgendem stand:");
|
|
|
|
}
|
2024-01-06 15:24:05 +01:00
|
|
|
}while(true);
|
2023-12-12 15:00:07 +01:00
|
|
|
|
2024-01-06 15:24:05 +01:00
|
|
|
spr.saveCsv("tmp/test.csv");
|
2023-12-12 15:00:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|