Bugfixes
This commit is contained in:
parent
b1a0fc9d3e
commit
aa38e7ef27
BIN
res/algebra.png
Normal file
BIN
res/algebra.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 KiB |
BIN
res/decimal.png
BIN
res/decimal.png
Binary file not shown.
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 6.5 KiB |
@ -233,8 +233,10 @@ public class Keyboard {
|
||||
case KeyEvent.VK_7:
|
||||
if (!Keyboard.shift && !Keyboard.alpha) {
|
||||
Keyboard.keyPressed(Key.NUM7);
|
||||
} else {
|
||||
Keyboard.keyPressed(Key.NONE);
|
||||
} else if (Keyboard.shift) {
|
||||
if (Utils.debugOn) {
|
||||
Keyboard.keyPressed(Key.DIVIDE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KeyEvent.VK_8:
|
||||
@ -740,12 +742,14 @@ public class Keyboard {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (k != Key.SHIFT && Keyboard.shift) {
|
||||
Keyboard.shift = false;
|
||||
refresh = true;
|
||||
} else if (k != Key.ALPHA && Keyboard.alpha) {
|
||||
Keyboard.alpha = false;
|
||||
refresh = true;
|
||||
if (Utils.debugOn == false) {
|
||||
if (k != Key.SHIFT && Keyboard.shift) {
|
||||
Keyboard.shift = false;
|
||||
refresh = true;
|
||||
} else if (k != Key.ALPHA && Keyboard.alpha) {
|
||||
Keyboard.alpha = false;
|
||||
refresh = true;
|
||||
}
|
||||
}
|
||||
if (refresh) {
|
||||
// PIDisplay.display.repaint();
|
||||
|
@ -446,7 +446,7 @@ public final class DisplayManager implements RenderingLoop {
|
||||
});
|
||||
dbgthrd.setDaemon(true);
|
||||
dbgthrd.setName("Debug performance thread");
|
||||
dbgthrd.start();
|
||||
//dbgthrd.start();
|
||||
|
||||
engine.start(this);
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class SwingWindow extends JFrame {
|
||||
setResizable(false);
|
||||
}
|
||||
|
||||
setTitle("Raspberry PI Calculator by XDrake99 (Andrea Cavalli)");
|
||||
setTitle("WarpPI Calculator by Andrea Cavalli (XDrake99)");
|
||||
|
||||
addComponentListener(new ComponentListener() {
|
||||
@Override
|
||||
@ -165,9 +165,17 @@ public class SwingWindow extends JFrame {
|
||||
break;
|
||||
case KeyEvent.VK_SHIFT:
|
||||
Keyboard.keyReleased(Key.SHIFT);
|
||||
if (Keyboard.shift) {
|
||||
Keyboard.keyPressed(Key.SHIFT);
|
||||
Keyboard.keyReleased(Key.SHIFT);
|
||||
}
|
||||
break;
|
||||
case KeyEvent.VK_A:
|
||||
Keyboard.keyReleased(Key.ALPHA);
|
||||
if (Keyboard.alpha) {
|
||||
Keyboard.keyPressed(Key.ALPHA);
|
||||
Keyboard.keyReleased(Key.ALPHA);
|
||||
}
|
||||
break;
|
||||
case KeyEvent.VK_M:
|
||||
Keyboard.keyPressed(Key.SURD_MODE);
|
||||
|
@ -126,6 +126,7 @@ public class GPUEngine implements org.warp.picalculator.gui.graphicengine.Graphi
|
||||
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
if (true) return false;
|
||||
return GLProfile.isAvailable(GLProfile.GL2ES1);
|
||||
}
|
||||
|
||||
|
@ -60,38 +60,9 @@ import org.warp.picalculator.gui.DisplayManager;
|
||||
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* __ __|_ ___________________________________________________________________________ ___|__ __
|
||||
* // /\ _ /\ \\
|
||||
* //____/ \__ __ _____ _____ _____ _____ _____ | | __ _____ _____ __ __/ \____\\
|
||||
* \ \ / / __| | | __| _ | | _ | | | __| | | __| | /\ \ / /
|
||||
* \____\/_/ | | | | | | | | | | | __| | | | | | | | | | |__ " \_\/____/
|
||||
* /\ \ |_____|_____|_____|__|__|_|_|_|__| | | |_____|_____|_____|_____| _ / /\
|
||||
* / \____\ http://jogamp.org |_| /____/ \
|
||||
* \ / "' _________________________________________________________________________ `" \ /
|
||||
* \/____. .____\/
|
||||
* </pre>
|
||||
*
|
||||
* <p>
|
||||
* JOGL2 OpenGL ES 2 demo to expose and learn what the RAW OpenGL ES 2 API looks
|
||||
* like.
|
||||
*
|
||||
* Compile, run and enjoy:
|
||||
* wget
|
||||
* http://jogamp.org/deployment/jogamp-current/archive/jogamp-all-platforms.7z
|
||||
* 7z x jogamp-all-platforms.7z
|
||||
* cd jogamp-all-platforms
|
||||
* mkdir -p demos/es2
|
||||
* cd demos/es2
|
||||
* wget
|
||||
* https://raw.github.com/xranby/jogl-demos/master/src/demos/es2/RawGL2ES1demo.java
|
||||
* cd ../..
|
||||
* javac -cp jar/jogl-all.jar:jar/gluegen-rt.jar demos/es2/RawGL2ES1demo.java
|
||||
* java -cp jar/jogl-all.jar:jar/gluegen-rt.jar:. demos.es2.RawGL2ES1demo
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @author Xerxes Rånby (xranby)
|
||||
* @author Andrea Cavalli (XDRake99)
|
||||
*/
|
||||
|
||||
class NEWTWindow implements GLEventListener {
|
||||
@ -107,19 +78,6 @@ class NEWTWindow implements GLEventListener {
|
||||
public GLWindow window;
|
||||
|
||||
public void create() {
|
||||
/* This demo are based on the GL2ES1 GLProfile that uses common hardware acceleration
|
||||
* functionality of desktop OpenGL 3, 2 and mobile OpenGL ES 2 devices.
|
||||
* JogAmp JOGL will probe all the installed libGL.so, libEGL.so and libGLESv2.so librarys on
|
||||
* the system to find which one provide hardware acceleration for your GPU device.
|
||||
* Its common to find more than one version of these librarys installed on a system.
|
||||
* For example on a ARM Linux system JOGL may find
|
||||
* Hardware accelerated Nvidia tegra GPU drivers in: /usr/lib/nvidia-tegra/libEGL.so
|
||||
* Software rendered Mesa Gallium driver in: /usr/lib/arm-linux-gnueabi/mesa-egl/libEGL.so.1
|
||||
* Software rendered Mesa X11 in: /usr/lib/arm-linux-gnueabi/mesa/libGL.so
|
||||
* Good news!: JOGL does all this probing for you all you have to do are to ask for
|
||||
* the GLProfile you want to use.
|
||||
*/
|
||||
|
||||
System.out.println("Loading OpenGL...");
|
||||
System.out.println(GLProfile.glAvailabilityToString());
|
||||
if (!GLProfile.isAvailable(GLProfile.GL2ES1)) {
|
||||
@ -135,7 +93,7 @@ class NEWTWindow implements GLEventListener {
|
||||
final GLWindow glWindow = GLWindow.create(caps);
|
||||
window = glWindow;
|
||||
|
||||
glWindow.setTitle("Algebraic Calculator for Raspberry PI by Andrea Cavalli (XDrake99)");
|
||||
glWindow.setTitle("WarpPI Calculator by Andrea Cavalli (XDrake99)");
|
||||
|
||||
glWindow.addWindowListener(new WindowListener() {
|
||||
|
||||
@ -272,9 +230,17 @@ class NEWTWindow implements GLEventListener {
|
||||
case 0x15:
|
||||
case KeyEvent.VK_SHIFT:
|
||||
Keyboard.keyReleased(Key.SHIFT);
|
||||
if (Keyboard.shift) {
|
||||
Keyboard.keyPressed(Key.SHIFT);
|
||||
Keyboard.keyReleased(Key.SHIFT);
|
||||
}
|
||||
break;
|
||||
case KeyEvent.VK_A:
|
||||
Keyboard.keyReleased(Key.ALPHA);
|
||||
if (Keyboard.alpha) {
|
||||
Keyboard.keyPressed(Key.ALPHA);
|
||||
Keyboard.keyReleased(Key.ALPHA);
|
||||
}
|
||||
break;
|
||||
case KeyEvent.VK_M:
|
||||
Keyboard.keyPressed(Key.SURD_MODE);
|
||||
|
@ -256,7 +256,7 @@ public class MathInputScreen extends Screen {
|
||||
equazioneCorrente = nuovaEquazione;
|
||||
calc.f2 = calc.f;
|
||||
afterDoNextStep = true;
|
||||
simplify(MathInputScreen.this);
|
||||
simplify();
|
||||
});
|
||||
} catch (final Exception ex) {
|
||||
if (Utils.debugOn) {
|
||||
@ -273,7 +273,7 @@ public class MathInputScreen extends Screen {
|
||||
System.err.println(e.id);
|
||||
}
|
||||
} else {
|
||||
simplify(this);
|
||||
simplify();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -290,7 +290,7 @@ public class MathInputScreen extends Screen {
|
||||
try {
|
||||
try {
|
||||
if (afterDoNextStep) {
|
||||
simplify(this);
|
||||
simplify();
|
||||
} else {
|
||||
if (nuovaEquazione != equazioneCorrente && nuovaEquazione.length() > 0) {
|
||||
changeEquationScreen();
|
||||
@ -457,7 +457,7 @@ public class MathInputScreen extends Screen {
|
||||
nuovaEquazione = "";
|
||||
afterDoNextStep = false;
|
||||
if (calc.f != null) {
|
||||
calc.f.clear();
|
||||
calc.f = new ArrayList<>();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -546,7 +546,7 @@ public class MathInputScreen extends Screen {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void simplify(MathInputScreen mathInputScreen) {
|
||||
protected void simplify() {
|
||||
try {
|
||||
try {
|
||||
showVariablesDialog();
|
||||
@ -585,6 +585,7 @@ public class MathInputScreen extends Screen {
|
||||
rf.generateGraphics();
|
||||
}
|
||||
}
|
||||
Utils.debug.println(calc.f2.toString());
|
||||
} catch (final Exception ex) {
|
||||
if (Utils.debugOn) {
|
||||
ex.printStackTrace();
|
||||
@ -718,7 +719,6 @@ public class MathInputScreen extends Screen {
|
||||
if (runnable != null) {
|
||||
runnable.run();
|
||||
}
|
||||
Utils.debug.println(calc.f.toString());
|
||||
}
|
||||
});
|
||||
ct.setName("Variables user-input queue thread");
|
||||
|
@ -9,6 +9,8 @@ import org.warp.picalculator.gui.graphicengine.cpu.CPUEngine;
|
||||
import org.warp.picalculator.math.Calculator;
|
||||
import org.warp.picalculator.math.MathematicalSymbols;
|
||||
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;
|
||||
@ -40,11 +42,25 @@ public class Division extends FunctionTwoValues {
|
||||
if (FractionsRule3.compare(this)) {
|
||||
return true;
|
||||
}
|
||||
if (FractionsRule11.compare(this)) {
|
||||
return true;
|
||||
}
|
||||
if (FractionsRule12.compare(this)) {
|
||||
return true;
|
||||
}
|
||||
if (UndefinedRule2.compare(this)) {
|
||||
return true;
|
||||
}
|
||||
if (variable1 instanceof Number && variable2 instanceof Number && root.exactMode == false) {
|
||||
return true;
|
||||
if (variable1 instanceof Number && variable2 instanceof Number) {
|
||||
if (root.exactMode) {
|
||||
try {
|
||||
return ((Number)variable1).divide((Number)variable2).isInteger();
|
||||
} catch (Error e) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -58,9 +74,13 @@ public class Division extends FunctionTwoValues {
|
||||
result = FractionsRule2.execute(this);
|
||||
} else if (FractionsRule3.compare(this)) {
|
||||
result = FractionsRule3.execute(this);
|
||||
} else if (FractionsRule11.compare(this)) {
|
||||
result = FractionsRule11.execute(this);
|
||||
} else if (FractionsRule12.compare(this)) {
|
||||
result = FractionsRule12.execute(this);
|
||||
} else if (UndefinedRule2.compare(this)) {
|
||||
result = UndefinedRule2.execute(this);
|
||||
} else if (variable1 instanceof Number && variable2 instanceof Number && root.exactMode == false) {
|
||||
} else if (variable1 instanceof Number && variable2 instanceof Number) {
|
||||
result.add(((Number) variable1).divide((Number) variable2));
|
||||
}
|
||||
return result;
|
||||
|
@ -32,6 +32,10 @@ public class Expression extends FunctionMultipleValues {
|
||||
super(root, values);
|
||||
}
|
||||
|
||||
public Expression(Calculator root, Function value) {
|
||||
super(root, new Function[]{value});
|
||||
}
|
||||
|
||||
private boolean initialParenthesis = false;
|
||||
|
||||
public Expression(Calculator root, String string) throws Error {
|
||||
@ -616,7 +620,7 @@ public class Expression extends FunctionMultipleValues {
|
||||
} else {
|
||||
if (functions.length == 1) {
|
||||
final Function f = functions[0];
|
||||
if (f instanceof Number || f instanceof Variable || f instanceof Expression || f instanceof Division || f instanceof Joke || f instanceof Undefined || f instanceof Power || f instanceof Sine || f instanceof Cosine || f instanceof Tangent || f instanceof ArcSine || f instanceof ArcCosine || f instanceof ArcTangent) {
|
||||
if (f instanceof Number || f instanceof Variable || f instanceof Expression || f instanceof Division || f instanceof Joke || f instanceof Undefined || f instanceof Power || f instanceof Sine || f instanceof Cosine || f instanceof Tangent || f instanceof ArcSine || f instanceof ArcCosine || f instanceof ArcTangent || f instanceof RootSquare) {
|
||||
parenthesisneeded = false;
|
||||
}
|
||||
if (f instanceof Multiplication) {
|
||||
|
@ -6,6 +6,7 @@ import org.warp.picalculator.Error;
|
||||
import org.warp.picalculator.math.Calculator;
|
||||
import org.warp.picalculator.math.MathematicalSymbols;
|
||||
import org.warp.picalculator.math.rules.ExponentRule15;
|
||||
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.NumberRule6;
|
||||
@ -52,6 +53,9 @@ public class Multiplication extends FunctionTwoValues {
|
||||
if (ExponentRule15.compare(this)) {
|
||||
return true;
|
||||
}
|
||||
if (FractionsRule14.compare(this)) {
|
||||
return true;
|
||||
}
|
||||
if (MultiplicationMethod1.compare(this)) {
|
||||
return true;
|
||||
}
|
||||
@ -71,6 +75,8 @@ public class Multiplication extends FunctionTwoValues {
|
||||
result = NumberRule6.execute(this);
|
||||
} else if (ExponentRule15.compare(this)) {
|
||||
result = ExponentRule15.execute(this);
|
||||
} else if (FractionsRule14.compare(this)) {
|
||||
result = FractionsRule14.execute(this);
|
||||
} else if (MultiplicationMethod1.compare(this)) {
|
||||
result = MultiplicationMethod1.execute(this);
|
||||
} else if (variable1.isSolved() & variable2.isSolved()) {
|
||||
@ -122,8 +128,12 @@ public class Multiplication extends FunctionTwoValues {
|
||||
}
|
||||
ok[val] = true;
|
||||
} else if (tmpVar[val] instanceof Expression) {
|
||||
ok[0] = true;
|
||||
ok[1] = true;
|
||||
if (((Expression)tmpVar[val]).parenthesisNeeded() == true) {
|
||||
ok[0] = true;
|
||||
ok[1] = true;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else if (tmpVar[val] instanceof FunctionTwoValues) {
|
||||
if (val == 0) {
|
||||
tmpVar[val] = ((FunctionTwoValues) tmpVar[val]).variable2;
|
||||
|
@ -7,6 +7,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.nevec.rjm.BigDecimalMath;
|
||||
import org.nevec.rjm.BigIntegerMath;
|
||||
import org.warp.picalculator.Error;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.gui.DisplayManager;
|
||||
@ -228,15 +229,34 @@ public class Number implements Function {
|
||||
|
||||
@Override
|
||||
public boolean isSolved() {
|
||||
return true;
|
||||
if (root.exactMode) {
|
||||
return isInteger();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Function> solveOneStep() throws Error {
|
||||
final List<Function> result = new ArrayList<>();
|
||||
result.add(this);
|
||||
if (root.exactMode) {
|
||||
Number divisor = new Number(root, BigInteger.TEN.pow(getNumberOfDecimalPlaces()));
|
||||
Number numb = new Number(root, term.multiply(divisor.term));
|
||||
Division div = new Division(root, numb, divisor);
|
||||
result.add(div);
|
||||
} else {
|
||||
result.add(this);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getNumberOfDecimalPlaces() {
|
||||
return Math.max(0, term.stripTrailingZeros().scale());
|
||||
}
|
||||
|
||||
public boolean isInteger() {
|
||||
return getNumberOfDecimalPlaces() <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
52
src/org/warp/picalculator/math/rules/FractionsRule11.java
Normal file
52
src/org/warp/picalculator/math/rules/FractionsRule11.java
Normal file
@ -0,0 +1,52 @@
|
||||
package org.warp.picalculator.math.rules;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.warp.picalculator.Error;
|
||||
import org.warp.picalculator.math.functions.Division;
|
||||
import org.warp.picalculator.math.functions.Expression;
|
||||
import org.warp.picalculator.math.functions.Function;
|
||||
import org.warp.picalculator.math.functions.Multiplication;
|
||||
|
||||
/**
|
||||
* Fractions rule<br>
|
||||
* <b>a / (b / c) = (a * c) / b</b>
|
||||
*
|
||||
* @author Andrea Cavalli
|
||||
*
|
||||
*/
|
||||
public class FractionsRule11 {
|
||||
|
||||
public static boolean compare(Function f) {
|
||||
final Division fnc = (Division) f;
|
||||
Function a;
|
||||
Function c;
|
||||
Division div2;
|
||||
if (fnc.getVariable2() instanceof Division) {
|
||||
div2 = (Division) fnc.getVariable2();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
a = fnc.getVariable1();
|
||||
c = div2.getVariable2();
|
||||
return new Multiplication(fnc.getRoot(), a, c).isSolved() == false;
|
||||
}
|
||||
|
||||
public static ArrayList<Function> execute(Function f) throws Error {
|
||||
final ArrayList<Function> result = new ArrayList<>();
|
||||
final Division fnc = (Division) f;
|
||||
Function a;
|
||||
Function b;
|
||||
Function c;
|
||||
|
||||
Division div2 = (Division) fnc.getVariable2();
|
||||
|
||||
a = fnc.getVariable1();
|
||||
b = div2.getVariable1();
|
||||
c = div2.getVariable2();
|
||||
result.add(new Division(fnc.getRoot(), new Multiplication(fnc.getRoot(), new Expression(fnc.getRoot(), a), new Expression(fnc.getRoot(), c)), b));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
49
src/org/warp/picalculator/math/rules/FractionsRule12.java
Normal file
49
src/org/warp/picalculator/math/rules/FractionsRule12.java
Normal file
@ -0,0 +1,49 @@
|
||||
package org.warp.picalculator.math.rules;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.warp.picalculator.Error;
|
||||
import org.warp.picalculator.math.functions.Division;
|
||||
import org.warp.picalculator.math.functions.Expression;
|
||||
import org.warp.picalculator.math.functions.Function;
|
||||
import org.warp.picalculator.math.functions.Multiplication;
|
||||
|
||||
/**
|
||||
* Fractions rule<br>
|
||||
* <b>(b / c) / a = b / (a * c)</b>
|
||||
*
|
||||
* @author Andrea Cavalli
|
||||
*
|
||||
*/
|
||||
public class FractionsRule12 {
|
||||
|
||||
public static boolean compare(Function f) {
|
||||
final Division fnc = (Division) f;
|
||||
Function a;
|
||||
Function c;
|
||||
if (fnc.getVariable1() instanceof Division) {
|
||||
final Division div2 = (Division) fnc.getVariable1();
|
||||
a = fnc.getVariable1();
|
||||
c = div2.getVariable2();
|
||||
return new Multiplication(fnc.getRoot(), a, c).isSolved() == false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ArrayList<Function> execute(Function f) throws Error {
|
||||
final ArrayList<Function> result = new ArrayList<>();
|
||||
final Division fnc = (Division) f;
|
||||
Function a;
|
||||
Function b;
|
||||
Function c;
|
||||
|
||||
final Division div2 = (Division) fnc.getVariable1();
|
||||
a = fnc.getVariable2();
|
||||
b = div2.getVariable1();
|
||||
c = div2.getVariable2();
|
||||
result.add(new Division(fnc.getRoot(), new Multiplication(fnc.getRoot(), new Expression(fnc.getRoot(), a), new Expression(fnc.getRoot(), c)), b));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
85
src/org/warp/picalculator/math/rules/FractionsRule14.java
Normal file
85
src/org/warp/picalculator/math/rules/FractionsRule14.java
Normal file
@ -0,0 +1,85 @@
|
||||
package org.warp.picalculator.math.rules;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.warp.picalculator.Error;
|
||||
import org.warp.picalculator.math.functions.Division;
|
||||
import org.warp.picalculator.math.functions.Expression;
|
||||
import org.warp.picalculator.math.functions.Function;
|
||||
import org.warp.picalculator.math.functions.Multiplication;
|
||||
|
||||
/**
|
||||
* Fractions rule<br>
|
||||
* <b>(a / b) * (c / d) = (a * c) / (b * d)</b>
|
||||
*
|
||||
* @author Andrea Cavalli
|
||||
*
|
||||
*/
|
||||
public class FractionsRule14 {
|
||||
|
||||
public static boolean compare(Function f) {
|
||||
final Multiplication fnc = (Multiplication) f;
|
||||
Function a;
|
||||
Function b;
|
||||
Function c;
|
||||
Function d;
|
||||
if (fnc.getVariable1() instanceof Division && fnc.getVariable2() instanceof Division) {
|
||||
final Division div1 = (Division) fnc.getVariable1();
|
||||
final Division div2 = (Division) fnc.getVariable2();
|
||||
a = div1.getVariable1();
|
||||
b = div1.getVariable2();
|
||||
c = div2.getVariable1();
|
||||
d = div2.getVariable2();
|
||||
return new Multiplication(f.getRoot(), a, c).isSolved() == false || new Multiplication(f.getRoot(), b, d).isSolved() == false;
|
||||
} else if (fnc.getVariable1() instanceof Division) {
|
||||
final Division div1 = (Division) fnc.getVariable1();
|
||||
a = div1.getVariable1();
|
||||
b = div1.getVariable2();
|
||||
c = fnc.getVariable2();
|
||||
return new Multiplication(f.getRoot(), a, c).isSolved() == false;
|
||||
} else if (fnc.getVariable2() instanceof Division) {
|
||||
final Division div2 = (Division) fnc.getVariable2();
|
||||
a = fnc.getVariable1();
|
||||
c = div2.getVariable1();
|
||||
d = div2.getVariable2();
|
||||
return new Multiplication(f.getRoot(), a, c).isSolved() == false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ArrayList<Function> execute(Function f) throws Error {
|
||||
final ArrayList<Function> result = new ArrayList<>();
|
||||
final Multiplication fnc = (Multiplication) f;
|
||||
Function a;
|
||||
Function b;
|
||||
Function c;
|
||||
Function d;
|
||||
|
||||
if (fnc.getVariable1() instanceof Division && fnc.getVariable2() instanceof Division) {
|
||||
final Division div1 = (Division) fnc.getVariable1();
|
||||
final Division div2 = (Division) fnc.getVariable2();
|
||||
a = div1.getVariable1();
|
||||
b = div1.getVariable2();
|
||||
c = div2.getVariable1();
|
||||
d = div2.getVariable2();
|
||||
final Division div = new Division(fnc.getRoot(), new Multiplication(fnc.getRoot(), new Expression(fnc.getRoot(), a), new Expression(fnc.getRoot(), c)), new Multiplication(fnc.getRoot(), new Expression(fnc.getRoot(), b), new Expression(fnc.getRoot(), d)));
|
||||
result.add(div);
|
||||
} else if (fnc.getVariable1() instanceof Division) {
|
||||
final Division div1 = (Division) fnc.getVariable1();
|
||||
a = div1.getVariable1();
|
||||
b = div1.getVariable2();
|
||||
c = fnc.getVariable2();
|
||||
final Division div = new Division(fnc.getRoot(), new Multiplication(fnc.getRoot(), new Expression(fnc.getRoot(), a), new Expression(fnc.getRoot(), c)), b);
|
||||
result.add(div);
|
||||
} else if (fnc.getVariable2() instanceof Division) {
|
||||
final Division div2 = (Division) fnc.getVariable2();
|
||||
a = fnc.getVariable1();
|
||||
c = div2.getVariable1();
|
||||
d = div2.getVariable2();
|
||||
final Division div = new Division(fnc.getRoot(), new Multiplication(fnc.getRoot(), new Expression(fnc.getRoot(), a), new Expression(fnc.getRoot(), c)), d);
|
||||
result.add(div);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user