From 1aa39e73446ca0dcf3b159efccae5b7067bf8ed0 Mon Sep 17 00:00:00 2001 From: Jan Bachmann <3010330@stud.hs-mannheim.de> Date: Sun, 7 Jan 2024 23:32:20 +0100 Subject: [PATCH] Dateien nach "Axel/src/de/hs_mannheim/informatik/spreadsheet" hochladen test --- .../informatik/spreadsheet/Spreadsheet.java | 62 ++++--------------- 1 file changed, 11 insertions(+), 51 deletions(-) diff --git a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java index 1760287..8c8dbac 100644 --- a/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java +++ b/Axel/src/de/hs_mannheim/informatik/spreadsheet/Spreadsheet.java @@ -1,6 +1,5 @@ package de.hs_mannheim.informatik.spreadsheet; -import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; @@ -8,7 +7,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.ArrayList; import java.util.List; -import java.util.Scanner; /** @@ -36,23 +34,6 @@ public class Spreadsheet { for (int c = 0; c < colWithMax26; c++) cells[r][c] = new Cell(); } - /** - * Sets a Spreadsheet of size rows * cols. - * @param rows number of rows - * @param cols number of columns - */ - public void changeSize(int rows, int cols) { - cells = new Cell[0][0]; - - int rowWithMax99= Math.min(rows, 99); - int colWithMax26= Math.min(cols, 26); - - cells = new Cell[rowWithMax99][colWithMax26]; - - for (int r = 0; r < rowWithMax99; r++) - for (int c = 0; c < colWithMax26; c++) - cells[r][c] = new Cell(); - } // ----- /* @@ -74,7 +55,7 @@ public class Spreadsheet { cellName = cellName.toUpperCase(); return get(getRow(cellName), getCol(cellName)); } - void put(int row, int col, String value) { + private void put(int row, int col, String value) { if (!value.startsWith("=")) cells[row][col].setValue(value); else { @@ -105,34 +86,13 @@ public class Spreadsheet { /** * A method for reading in data from a CSV file. * @param path The file to read. - * @param startCellName The upper left cell where data from the CSV file should be inserted. + * @param separator The char used to split up the input, e.g. a comma or a semicolon. + * @param starCellName The upper left cell where data from the CSV file should be inserted. * @return Nothing. * @exception IOException If path does not exist. */ - public void readCsv(String path, String startCellName) throws FileNotFoundException { - Scanner csvIn = new Scanner(new File(path)); - int index= 0; - - while(csvIn.hasNextLine()){ - String line =csvIn.nextLine(); - String all=""; - int filled=0; - for(int i = 0;i args = new ArrayList<>(); for(int j = getRow(startCellName); j<= (getRow(endCellName));j++){ @@ -328,7 +288,7 @@ public class Spreadsheet { * @param endCellName The name of the cell in the lower right corner of the rectangle. * @return The maximum value calculated. */ - public long max(String startCellName, String endCellName) { + private long max(String startCellName, String endCellName) { long res = 0; List args = new ArrayList<>(); for(int j = getRow(startCellName); j<= (getRow(endCellName));j++){