104 lines
2.0 KiB
Java
104 lines
2.0 KiB
Java
package de.hs_mannheim.informatik.spreadsheet;
|
|
//m
|
|
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,20);
|
|
Scanner sc= new Scanner(System.in);
|
|
|
|
|
|
boolean exit=false;
|
|
String readInput;
|
|
String currentCell;
|
|
String formula;
|
|
String path;
|
|
|
|
spr.put("A3", "123");
|
|
spr.put("A2", "1");
|
|
|
|
spr.put("B9", "=41+A2");
|
|
spr.put("J5", "=7*6");
|
|
spr.put("J6", "=3/2");
|
|
|
|
//add some values for testing
|
|
spr.put("B1", "10");
|
|
spr.put("B2", "5");
|
|
spr.put("B3", "8");
|
|
|
|
|
|
//
|
|
|
|
System.out.println(spr);
|
|
|
|
spr.saveCsv("/tmp/test.csv");
|
|
|
|
// TODO: You might want to put "UI loop" for entering value and formulas here resp. in some UI methods.
|
|
|
|
do {
|
|
|
|
//set values in cells
|
|
|
|
System.out.println();
|
|
|
|
System.out.println("Do you want to load a csv File?(y/n)");
|
|
readInput=sc.nextLine();
|
|
if(readInput.equals("y")||readInput.equals("Y")) {
|
|
System.out.println("Paste the filpath here:");
|
|
readInput= sc.nextLine();
|
|
path=readInput;
|
|
spr.readCsv(path, ",", "A1");
|
|
|
|
|
|
}
|
|
|
|
|
|
System.out.println("cell name:");
|
|
readInput= sc.nextLine();
|
|
|
|
currentCell=readInput;
|
|
|
|
System.out.println("Set formula or value:");
|
|
|
|
readInput= sc.nextLine();
|
|
|
|
formula=readInput;
|
|
|
|
spr.put(currentCell, formula);
|
|
|
|
System.out.println(spr);
|
|
|
|
System.out.println();
|
|
|
|
System.out.println("Do you want to save the sheet?(y/n)");
|
|
readInput=sc.nextLine();
|
|
if(readInput.equals("y")||readInput.equals("Y")) {
|
|
spr.saveCsv("test");
|
|
}
|
|
|
|
|
|
System.out.println("Exit? y/n");
|
|
|
|
readInput= sc.nextLine();
|
|
if(readInput.equals("y")||readInput.equals("Y"))
|
|
exit=true;
|
|
|
|
}
|
|
|
|
while(!exit);
|
|
|
|
System.out.println("Programmende.");
|
|
|
|
}
|
|
|
|
|
|
|
|
} |