sum() Methode ergänzt

Anastasia Kisner 2024-01-06 19:02:13 +01:00
parent 44e9e9bc9c
commit bbbaf7473a
1 changed files with 14 additions and 4 deletions

View File

@ -76,7 +76,6 @@ public class Spreadsheet {
* @param path The file to read.
* @param separator The char used to split up the input, e.g. a comma or a semicolon.
* @param startCellName 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, char separator, String startCellName) throws FileNotFoundException {
@ -86,7 +85,6 @@ public class Spreadsheet {
/**
* A method for saving data to a CSV file.
* @param path The file to write.
* @return Nothing.
* @exception IOException If path does not exist.
*/
public void saveCsv(String path) throws FileNotFoundException {
@ -112,7 +110,6 @@ public class Spreadsheet {
* This method does the actual evaluation/calcluation of a specific cell
* @param row the row of the cell to be evaluated
* @param col the col of the cell to be evaluated
* @return Nothing.
*/
private void evaluateCell(int row, int col) {
String formula = cells[row][col].getFormula();
@ -150,8 +147,21 @@ public class Spreadsheet {
* @return The sum calculated.
*/
private long sum(String startCellName, String endCellName) {
long result = 0;
return 0;
for(char col = startCellName.charAt(0); col <= endCellName.charAt(0); col++){
for(int row = Integer.parseInt(startCellName.substring(1)); row <= Integer.parseInt(endCellName.substring(1)); row++) {
String value = get((row - 1), (col - 'A'));
System.out.println(value);
if(!value.isEmpty()){
result += Long.parseLong(value);
}
}
}
return result;
}
/**