forked from hummel/PR1-Spreadsheet
Compare commits
No commits in common. "361527e2b4a31ab23e79974516510a3f3e375901" and "4f38207c3b214985ccdec38567dac049cd981b41" have entirely different histories.
361527e2b4
...
4f38207c3b
|
@ -11,7 +11,6 @@ import java.util.Scanner;
|
|||
public class Axel {
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException {
|
||||
/*
|
||||
Spreadsheet spr = new Spreadsheet(100,100);
|
||||
|
||||
spr.put("A1", "123");
|
||||
|
@ -23,62 +22,27 @@ public class Axel {
|
|||
|
||||
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);
|
||||
|
||||
//spr.saveCsv("C:\\Users\\flori\\IdeaProjects\\PR1-Spreadsheet\\Axel\\resources\\zahlen.csv");
|
||||
//spr.readCsv("C:\\Users\\flori\\IdeaProjects\\PR1-Spreadsheet\\Axel\\resources\\zahlen2.csv", ',',"A1");
|
||||
|
||||
|
||||
//spr.readCsv("C:\\Users\\flori\\IdeaProjects\\PR1-Spreadsheet\\Axel\\resources\\zahlen2.csv", ',',"A1");
|
||||
//System.out.println(spr);
|
||||
|
||||
|
||||
// TODO: You might want to put "UI loop" for entering value and formulas here resp. in some UI methods.
|
||||
|
||||
String eingabe = "";
|
||||
String merker = "";
|
||||
|
||||
String path, startcell;
|
||||
char separator;
|
||||
|
||||
System.out.println("Willkommen zum Spreadsheet Programm");
|
||||
System.out.println();
|
||||
System.out.println("Wie groß soll das Spreadsheet sein?");
|
||||
System.out.print("Zeilen(1-26): ");
|
||||
eingabe = abfrage();
|
||||
int zeilen = Integer.parseInt(eingabe);
|
||||
System.out.print("Spalten(1-99): ");
|
||||
eingabe = abfrage();
|
||||
int spalten = Integer.parseInt(eingabe);;
|
||||
|
||||
Spreadsheet spr = new Spreadsheet(zeilen,spalten);
|
||||
|
||||
do {
|
||||
System.out.println();
|
||||
System.out.println(spr);
|
||||
do {System.out.println(spr);
|
||||
System.out.println();
|
||||
System.out.print("Weitere Zelle bearbeiten?(J/N): ");
|
||||
eingabe = abfrage();
|
||||
if (eingabe.equals("N") || eingabe.equals("n") || eingabe.equals("nein") ||eingabe.equals("Nein")) {
|
||||
System.out.print("Dafür eine \"csv\" Datei einlesen?(J/N): ");
|
||||
eingabe = abfrage();
|
||||
if (eingabe.equals("N") || eingabe.equals("n") || eingabe.equals("nein") ||eingabe.equals("Nein")) {
|
||||
break;
|
||||
}else {
|
||||
System.out.print("Path von der csv Datei: ");
|
||||
eingabe = abfrage();
|
||||
path = eingabe;
|
||||
|
||||
System.out.print("Separator zwischen den Zellen in der csb Datei: ");
|
||||
eingabe = abfrage();
|
||||
separator = eingabe.charAt(0);
|
||||
|
||||
System.out.print("Obere Linke Zelle, in die Daten aus der csb-Datei eingefügt werden sollen: ");
|
||||
eingabe = abfrage();
|
||||
startcell = eingabe;
|
||||
|
||||
spr.readCsv(path, separator,startcell);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
do {
|
||||
|
@ -107,8 +71,7 @@ public class Axel {
|
|||
}
|
||||
|
||||
private static void verabschiedung(Spreadsheet spr) throws FileNotFoundException {
|
||||
System.out.println("Programm wird gleich beendet!");
|
||||
System.out.print("Wollen Sie vorher Ihre Tabelle vorher abspeichern?(J/N): ");
|
||||
System.out.println("Programm wird beendet. Wollen Sie Ihre Tabelle vorher abspeichern?");
|
||||
|
||||
String kbord = abfrage();
|
||||
kbord = kbord.toUpperCase();
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
package de.hs_mannheim.informatik.spreadsheet;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Scanner;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* A simplified spreadsheet class for the PR1 programming lab at Hochschule Mannheim.
|
||||
|
@ -124,30 +121,6 @@ public class Spreadsheet {
|
|||
*/
|
||||
public void readCsv(String path, char separator, String startCellName) throws FileNotFoundException {
|
||||
// TODO: implement this
|
||||
ArrayList<String> lines = readFile(path);
|
||||
String[] einzelnde_lines = new String[lines.size()];
|
||||
int row_startcell = getRow(startCellName);
|
||||
int col_startcell = getCol(startCellName);
|
||||
String[][] zwischenspeicher = new String[cells.length - row_startcell][cells[0].length - col_startcell];
|
||||
for (int i = 0; i < einzelnde_lines.length; i++) {
|
||||
zwischenspeicher[i] = lines.get(i).split(separator+""); // +"" um aus dem Char ein String zu machen
|
||||
for (int j = 0; j < zwischenspeicher[i].length; j++) {
|
||||
put(row_startcell+i,col_startcell+j,zwischenspeicher[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<String> readFile(String path) throws FileNotFoundException {
|
||||
ArrayList<String> lines = new ArrayList<>();
|
||||
Scanner sc = new Scanner(new File(path));
|
||||
|
||||
while (sc.hasNextLine()) {
|
||||
lines.add(sc.nextLine());
|
||||
}
|
||||
|
||||
sc.close();
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue