sum() Methode ergänzt
parent
44e9e9bc9c
commit
bbbaf7473a
|
@ -76,7 +76,6 @@ public class Spreadsheet {
|
||||||
* @param path The file to read.
|
* @param path The file to read.
|
||||||
* @param separator The char used to split up the input, e.g. a comma or a semicolon.
|
* @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.
|
* @param startCellName The upper left cell where data from the CSV file should be inserted.
|
||||||
* @return Nothing.
|
|
||||||
* @exception IOException If path does not exist.
|
* @exception IOException If path does not exist.
|
||||||
*/
|
*/
|
||||||
public void readCsv(String path, char separator, String startCellName) throws FileNotFoundException {
|
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.
|
* A method for saving data to a CSV file.
|
||||||
* @param path The file to write.
|
* @param path The file to write.
|
||||||
* @return Nothing.
|
|
||||||
* @exception IOException If path does not exist.
|
* @exception IOException If path does not exist.
|
||||||
*/
|
*/
|
||||||
public void saveCsv(String path) throws FileNotFoundException {
|
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
|
* This method does the actual evaluation/calcluation of a specific cell
|
||||||
* @param row the row of the cell to be evaluated
|
* @param row the row of the cell to be evaluated
|
||||||
* @param col the col 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) {
|
private void evaluateCell(int row, int col) {
|
||||||
String formula = cells[row][col].getFormula();
|
String formula = cells[row][col].getFormula();
|
||||||
|
@ -150,8 +147,21 @@ public class Spreadsheet {
|
||||||
* @return The sum calculated.
|
* @return The sum calculated.
|
||||||
*/
|
*/
|
||||||
private long sum(String startCellName, String endCellName) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue