1
0
Fork 0

Produktrechnung implementiert

master
devra 2024-01-08 21:12:35 +01:00
parent 9197f30031
commit bc13be8b44
2 changed files with 21 additions and 6 deletions

View File

@ -0,0 +1,10 @@
=SUMME(C1:E2),,=1,=2,=3,,,,,
,,=4,=5,=6,,,,,
,,,,=0,,,,,
,,,,=0,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
1 =SUMME(C1:E2) =1 =2 =3
2 =4 =5 =6
3 =0
4 =0
5
6
7
8
9
10

View File

@ -155,8 +155,11 @@ public class Spreadsheet {
}
else if (formula.startsWith("PRODUKT(")) {// e.g. PRODUKT(A3:B9)
String[] onlyCells = formula.substring(8, formula.length() - 1).split(":");
result = "TODO"; // TODO
if(checkIfCellExists(onlyCells[0])&&checkIfCellExists(onlyCells[1])) {
result = "" + pro(onlyCells[0], onlyCells[1]);
}
}
@ -200,7 +203,7 @@ public class Spreadsheet {
private long pro(String startCellName, String endCellName) {
int werte[]=getValues(startCellName,endCellName);
int produkt=0;
int produkt=1;
for(int i=0;i<werte.length;i++) {
produkt*=werte[i];
}
@ -226,10 +229,12 @@ public class Spreadsheet {
int[] werte = new int[(wahreEndZeile - wahreStartZeile + 1) * (wahreEndSpalte - wahreStartSpalte + 1)];
int i=0;
for(int z=wahreStartZeile;z<=wahreEndZeile;z++) {
for(int s=wahreStartSpalte;s<=wahreEndSpalte;s++) {
werte[i] = Integer.parseInt(get(z, s));
i++;
for (int z = wahreStartZeile; z <= wahreEndZeile; z++) {
for (int s = wahreStartSpalte; s <= wahreEndSpalte; s++) {
if (!get(z, s).isBlank()) {
werte[i] = Integer.parseInt(get(z, s)); // Update the element if it's a number
i++;
}
}
}