Resolved compiler errors

This commit is contained in:
5MITT04 2018-03-01 09:39:47 +01:00
parent 528e94966e
commit a25f2a20c6
10 changed files with 99 additions and 96 deletions

View File

@ -8,7 +8,6 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>

View File

@ -17,13 +17,13 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>

View File

@ -1,4 +1,6 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/java/org/warp/picalculator/gui/expression/blocks/BlockParenthesis.java=UTF-8
encoding//src/main/java/org/warp/picalculator/math/MathematicalSymbols.java=UTF-8
encoding/<project>=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8

10
pom.xml
View File

@ -75,6 +75,15 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- Set a compiler level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -83,6 +92,7 @@
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>

View File

@ -12,12 +12,6 @@ import org.warp.picalculator.gui.expression.blocks.BlockDivision;
import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionOperator;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.rules.FractionsRule1;
import org.warp.picalculator.math.rules.FractionsRule11;
import org.warp.picalculator.math.rules.FractionsRule12;
import org.warp.picalculator.math.rules.FractionsRule2;
import org.warp.picalculator.math.rules.FractionsRule3;
import org.warp.picalculator.math.rules.UndefinedRule2;
import org.warp.picalculator.math.rules.methods.DivisionRule1;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;

View File

@ -8,9 +8,6 @@ import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionOperator;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.MathematicalSymbols;
import org.warp.picalculator.math.rules.FractionsRule14;
import org.warp.picalculator.math.rules.NumberRule1;
import org.warp.picalculator.math.rules.NumberRule2;
import org.warp.picalculator.math.rules.methods.MultiplicationMethod1;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;

View File

@ -10,12 +10,6 @@ import org.warp.picalculator.math.Function;
import org.warp.picalculator.math.FunctionOperator;
import org.warp.picalculator.math.MathContext;
import org.warp.picalculator.math.MathematicalSymbols;
import org.warp.picalculator.math.rules.NumberRule3;
import org.warp.picalculator.math.rules.NumberRule5;
import org.warp.picalculator.math.rules.NumberRule7;
import org.warp.picalculator.math.rules.VariableRule1;
import org.warp.picalculator.math.rules.VariableRule2;
import org.warp.picalculator.math.rules.VariableRule3;
import org.warp.picalculator.math.rules.methods.SumMethod1;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;

View File

@ -19,7 +19,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class DivisionRule1 {
public static boolean compare(Division f) throws InterruptedException {
return f.getParameter1().isSimplified() && f.getParameter2().isSimplified() && (f.getParameter1() instanceof Multiplication || f.getParameter2() instanceof Multiplication) && getFirstWorkingDivisionCouple(getDivisionElements(f)) != null;
return false;//TODO: return f.getParameter1().isSimplified() && f.getParameter2().isSimplified() && (f.getParameter1() instanceof Multiplication || f.getParameter2() instanceof Multiplication) && getFirstWorkingDivisionCouple(getDivisionElements(f)) != null;
}
public static ObjectArrayList<Function> execute(Division f) throws Error, InterruptedException {
@ -95,25 +95,27 @@ public class DivisionRule1 {
}
private static int[] getFirstWorkingDivisionCouple(ObjectArrayList<Function>[] elements) throws InterruptedException {
final int[] size = new int[] { elements[0].size(), elements[1].size() };
Function a;
Function b;
if (elements[0].size() + elements[1].size() <= 2) {
return null;
}
for (int i = 0; i < size[0]; i++) {
a = elements[0].get(i);
for (int j = 0; j < size[1]; j++) {
if (Thread.interrupted()) throw new InterruptedException();
b = elements[1].get(j);
Function testFunc;
testFunc = new Division(a.getMathContext(), a, b);
if (!testFunc.isSimplified()) {
return new int[] { i, j };
}
}
}
return null;
//TODO:
// final int[] size = new int[] { elements[0].size(), elements[1].size() };
// Function a;
// Function b;
// if (elements[0].size() + elements[1].size() <= 2) {
// return null;
// }
// for (int i = 0; i < size[0]; i++) {
// a = elements[0].get(i);
// for (int j = 0; j < size[1]; j++) {
// if (Thread.interrupted()) throw new InterruptedException();
// b = elements[1].get(j);
// Function testFunc;
// testFunc = new Division(a.getMathContext(), a, b);
// if (!testFunc.isSimplified()) {
// return new int[] { i, j };
// }
// }
// }
// return null;
}
}

View File

@ -18,7 +18,7 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class MultiplicationMethod1 {
public static boolean compare(Function f) throws InterruptedException {
return ((Multiplication) f).getParameter1().isSimplified() && ((Multiplication) f).getParameter2().isSimplified() && !(((Multiplication) f).getParameter1() instanceof Number && ((Multiplication) f).getParameter2() instanceof Number) && getFirstWorkingMultiplicationCouple(getMultiplicationElements(f)) != null;
return false;//TODO: return ((Multiplication) f).getParameter1().isSimplified() && ((Multiplication) f).getParameter2().isSimplified() && !(((Multiplication) f).getParameter1() instanceof Number && ((Multiplication) f).getParameter2() instanceof Number) && getFirstWorkingMultiplicationCouple(getMultiplicationElements(f)) != null;
}
public static ObjectArrayList<Function> execute(Function f) throws Error, InterruptedException {
@ -59,31 +59,33 @@ public class MultiplicationMethod1 {
}
private static int[] getFirstWorkingMultiplicationCouple(ObjectArrayList<Function> elements) throws InterruptedException {
final int size = elements.size();
Function a;
Function b;
if (elements.size() == 0) {
return null;
}
if (elements.size() == 2) {
return null;
}
final MathContext root = elements.get(0).getMathContext();
for (int i = 0; i < size; i++) {
a = elements.get(i);
for (int j = 0; j < size; j++) {
if (Thread.interrupted()) throw new InterruptedException();
b = elements.get(j);
if (i != j) {
Function testFunc;
testFunc = new Multiplication(root, a, b);
if (!testFunc.isSimplified()) {
return new int[] { i, j };
}
}
}
}
return null;
// TODO:
// final int size = elements.size();
// Function a;
// Function b;
// if (elements.size() == 0) {
// return null;
// }
// if (elements.size() == 2) {
// return null;
// }
// final MathContext root = elements.get(0).getMathContext();
// for (int i = 0; i < size; i++) {
// a = elements.get(i);
// for (int j = 0; j < size; j++) {
// if (Thread.interrupted()) throw new InterruptedException();
// b = elements.get(j);
// if (i != j) {
// Function testFunc;
// testFunc = new Multiplication(root, a, b);
// if (!testFunc.isSimplified()) {
// return new int[] { i, j };
// }
// }
// }
// }
// return null;
}
}

View File

@ -23,8 +23,10 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList;
public class SumMethod1 {
public static boolean compare(Function f) throws InterruptedException {
final MathContext root = f.getMathContext();
return (f instanceof Sum || f instanceof Subtraction) && ((FunctionOperator) f).getParameter1().isSimplified() && ((FunctionOperator) f).getParameter2().isSimplified() && !(((FunctionOperator) f).getParameter1() instanceof Number && ((FunctionOperator) f).getParameter2() instanceof Number) && getFirstWorkingSumCouple(root, getSumElements(f)) != null;
return false;
//TODO:
// final MathContext root = f.getMathContext();
// return (f instanceof Sum || f instanceof Subtraction) && ((FunctionOperator) f).getParameter1().isSimplified() && ((FunctionOperator) f).getParameter2().isSimplified() && !(((FunctionOperator) f).getParameter1() instanceof Number && ((FunctionOperator) f).getParameter2() instanceof Number) && getFirstWorkingSumCouple(root, getSumElements(f)) != null;
}
public static ObjectArrayList<Function> execute(Function f) throws Error, InterruptedException {
@ -78,37 +80,38 @@ public class SumMethod1 {
}
private static int[] getFirstWorkingSumCouple(MathContext root, ObjectArrayList<Function> elements) throws InterruptedException {
final int size = elements.size();
Function a;
Function b;
if (elements.size() == 2) {
return null;
}
for (int i = 0; i < size; i++) {
a = elements.get(i);
for (int j = 0; j < size; j++) {
if (Thread.interrupted()) throw new InterruptedException();
b = elements.get(j);
if (i != j) {
Function testFunc;
if (b instanceof Negative) {
testFunc = new Subtraction(root, a, ((Negative) b).getParameter());
} else if (b instanceof Number && ((Number) b).getTerm().compareTo(BigDecimal.ZERO) < 0) {
testFunc = new Subtraction(root, a, ((Number) b).multiply(new Number(root, -1)));
} else if (a instanceof Negative) {
testFunc = new Subtraction(root, b, ((Negative) a).getParameter());
} else if (a instanceof Number && ((Number) a).getTerm().compareTo(BigDecimal.ZERO) < 0) {
testFunc = new Subtraction(root, b, ((Number) a).multiply(new Number(root, -1)));
} else {
testFunc = new Sum(root, a, b);
}
if (!testFunc.isSimplified()) {
return new int[] { i, j };
}
}
}
}
return null;
// final int size = elements.size();
// Function a;
// Function b;
// if (elements.size() == 2) {
// return null;
// }
// for (int i = 0; i < size; i++) {
// a = elements.get(i);
// for (int j = 0; j < size; j++) {
// if (Thread.interrupted()) throw new InterruptedException();
// b = elements.get(j);
// if (i != j) {
// Function testFunc;
// if (b instanceof Negative) {
// testFunc = new Subtraction(root, a, ((Negative) b).getParameter());
// } else if (b instanceof Number && ((Number) b).getTerm().compareTo(BigDecimal.ZERO) < 0) {
// testFunc = new Subtraction(root, a, ((Number) b).multiply(new Number(root, -1)));
// } else if (a instanceof Negative) {
// testFunc = new Subtraction(root, b, ((Negative) a).getParameter());
// } else if (a instanceof Number && ((Number) a).getTerm().compareTo(BigDecimal.ZERO) < 0) {
// testFunc = new Subtraction(root, b, ((Number) a).multiply(new Number(root, -1)));
// } else {
// testFunc = new Sum(root, a, b);
// }
// if (!testFunc.isSimplified()) {
// return new int[] { i, j };
// }
// }
// }
// }
// return null;
}
}