forked from hummel/PR1-Spreadsheet
improving previous written code
parent
e8114209f2
commit
7f44b09aa4
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="src" path="Axel/src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>PR1-Spreadsheet</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -68,10 +68,7 @@ public class Spreadsheet {
|
|||
}
|
||||
|
||||
private int getRow(String cellName) {
|
||||
if(cellName.length()==3)
|
||||
return Integer.parseInt((cellName.charAt(1)+"")+(cellName.charAt(2)+""))-1;
|
||||
else
|
||||
return cellName.charAt(1) - '1';
|
||||
return Integer.parseInt(cellName.substring(1))-1;
|
||||
}
|
||||
|
||||
// -----
|
||||
|
@ -164,18 +161,8 @@ public class Spreadsheet {
|
|||
*/
|
||||
private long sum(String startCellName, String endCellName) {
|
||||
int sum=0;
|
||||
int startCellRow;
|
||||
int endCellRow;
|
||||
if(startCellName.length()==3)
|
||||
startCellRow=Integer.parseInt((startCellName.charAt(1)+"")+(startCellName.charAt(2)+""))-1;
|
||||
else
|
||||
startCellRow=startCellName.charAt(1)-'1';
|
||||
if(endCellName.length()==3)
|
||||
endCellRow=Integer.parseInt((endCellName.charAt(1)+"")+(endCellName.charAt(2)+""))-1;
|
||||
else
|
||||
endCellRow=endCellName.charAt(1)-'1';
|
||||
for(int i=startCellName.charAt(0)-'A'; i<=endCellName.charAt(0)-'A'; i++) {
|
||||
for(int j=startCellRow; j<=endCellRow; j++) {
|
||||
for(int j=Integer.parseInt(startCellName.substring(1))-1; j<=Integer.parseInt(endCellName.substring(1))-1; j++) {
|
||||
if(cells[j][i].isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -186,18 +173,8 @@ public class Spreadsheet {
|
|||
}
|
||||
private long product(String startCellName, String endCellName) {
|
||||
int product=1;
|
||||
int startCellRow;
|
||||
int endCellRow;
|
||||
if(startCellName.length()==3)
|
||||
startCellRow=Integer.parseInt((startCellName.charAt(1)+"")+(startCellName.charAt(2)+""))-1;
|
||||
else
|
||||
startCellRow=startCellName.charAt(1)-'1';
|
||||
if(endCellName.length()==3)
|
||||
endCellRow=Integer.parseInt((endCellName.charAt(1)+"")+(endCellName.charAt(2)+""))-1;
|
||||
else
|
||||
endCellRow=endCellName.charAt(1)-'1';
|
||||
for(int i=startCellName.charAt(0)-'A'; i<=endCellName.charAt(0)-'A'; i++) {
|
||||
for(int j=startCellRow; j<=endCellRow; j++) {
|
||||
for(int j=Integer.parseInt(startCellName.substring(1))-1; j<=Integer.parseInt(endCellName.substring(1))-1; j++) {
|
||||
if(cells[j][i].isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue