55 lines
1.4 KiB
Java
55 lines
1.4 KiB
Java
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.
|
|
*
|
|
* @author Oliver Hummel
|
|
*/
|
|
public class Axel {
|
|
|
|
public static void main(String[] args) throws FileNotFoundException {
|
|
Spreadsheet spr = new Spreadsheet(10,10);
|
|
@SuppressWarnings("resource")
|
|
Scanner input = new Scanner(System.in);
|
|
|
|
spr.put("A3", "123");
|
|
|
|
spr.put("B9", "=41+A2+10-2/3");
|
|
spr.put("B9", "2");
|
|
|
|
System.out.println("Schreibe 'stop' zum anhalten.");
|
|
do{
|
|
String command = "";
|
|
String form = "";
|
|
String cell= "";
|
|
boolean cellTRUE = true;
|
|
System.out.println(spr);
|
|
System.out.println("Befehl (z.B. D4_=7*6): ");
|
|
command = input.nextLine();
|
|
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]+))")) {
|
|
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);
|
|
}
|
|
}
|
|
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:");
|
|
}
|
|
}while(true);
|
|
|
|
spr.saveCsv("tmp/test.csv");
|
|
}
|
|
|
|
} |