forked from hummel/PR1-Spreadsheet
Anfang von Menü bzw. UI-loop
parent
c23bcf7113
commit
ccf2d38603
|
@ -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.
|
||||
|
@ -10,7 +11,7 @@ import java.io.FileNotFoundException;
|
|||
public class Axel {
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException {
|
||||
Spreadsheet spr = new Spreadsheet(10,10);
|
||||
Spreadsheet spr = new Spreadsheet(100,100);
|
||||
|
||||
spr.put("A1", "123");
|
||||
spr.put("A2", "1");
|
||||
|
@ -20,6 +21,7 @@ public class Axel {
|
|||
spr.put("J6", "=3/2");
|
||||
|
||||
spr.put("J10", "1111"); // Das Programm konnte keine Zellen mit 2 Stellen (>9) einlesen! (-> Programm macht es an Stelle 1 statt 10)
|
||||
spr.put("Z2", "23");
|
||||
|
||||
System.out.println(spr);
|
||||
|
||||
|
@ -32,6 +34,41 @@ public class Axel {
|
|||
|
||||
|
||||
// TODO: You might want to put "UI loop" for entering value and formulas here resp. in some UI methods.
|
||||
|
||||
String eingabe = "";
|
||||
|
||||
do {
|
||||
|
||||
eingabe = abfrage();
|
||||
|
||||
}while(weiter(eingabe));
|
||||
verabschiedung();
|
||||
}
|
||||
|
||||
private static void verabschiedung() {
|
||||
System.out.println("Programm wird beendet. Wollen Sie Ihre Tabelle vorher abspeichern?");
|
||||
|
||||
String kbord = abfrage();
|
||||
kbord = kbord.toUpperCase();
|
||||
|
||||
if (kbord.equals("JA") || kbord.equals("J") || kbord.equals("Y") || kbord.equals("YES")) {
|
||||
System.out.println("Tabelle wurde gespeichert"); //TODO: Tabelle soll hier in einer csv Datei gespeichert werden
|
||||
}
|
||||
System.out.println("-Programm wurde beendet-");
|
||||
}
|
||||
|
||||
private static boolean weiter(String eingabe) {
|
||||
if (eingabe.equals("exit")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String abfrage() {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
String x = sc.nextLine();
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue