forked from hummel/PR1-Spreadsheet
sum of a cell block
parent
f19c749e0b
commit
9c5b38d9db
|
@ -15,12 +15,12 @@ public class Axel {
|
|||
String cell, in;
|
||||
Scanner kb = new Scanner(System.in);
|
||||
|
||||
spr.put("A3", "3");
|
||||
spr.put("A2", "1");
|
||||
//spr.put("A3", "3");
|
||||
//spr.put("A2", "1");
|
||||
|
||||
spr.put("B9", "=41+A2");
|
||||
spr.put("J5", "=7*6");
|
||||
spr.put("J6", "=3/2");
|
||||
//spr.put("B9", "=41+A2");
|
||||
//spr.put("J5", "=7*6");
|
||||
//spr.put("J6", "=3/2");
|
||||
|
||||
while(true) {
|
||||
System.out.println(spr);
|
||||
|
|
|
@ -150,9 +150,16 @@ public class Spreadsheet {
|
|||
* @return The sum calculated.
|
||||
*/
|
||||
private long sum(String startCellName, String endCellName) {
|
||||
// TODO implement
|
||||
|
||||
return 0;
|
||||
int sum=0;
|
||||
for(int i=startCellName.charAt(0)-'A'; i<=endCellName.charAt(0)-'A'; i++) {
|
||||
for(int j=startCellName.charAt(1)-'1'; j<=endCellName.charAt(1)-'1'; j++) {
|
||||
if(cells[i][j].isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
sum+=Integer.parseInt(cells[j][i].getValue());
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue