Multiple result support, Plus-Minus sign

This commit is contained in:
XDrake99 2016-09-18 14:33:25 +02:00
parent 2c13397919
commit c81df8bdc0
30 changed files with 837 additions and 130 deletions

Binary file not shown.

Binary file not shown.

View File

@ -130,7 +130,7 @@ public class Keyboard {
if (shift) {
keyPressed(Key.NONE);
} else if (alpha) {
keyPressed(Key.NONE);
keyPressed(Key.LETTER_Y);
} else {
keyPressed(Key.DOT);
}
@ -138,7 +138,7 @@ public class Keyboard {
if (shift) {
keyPressed(Key.NONE);
} else if (alpha) {
keyPressed(Key.NONE);
keyPressed(Key.LETTER_X);
} else {
keyPressed(Key.NUM0);
}
@ -216,7 +216,7 @@ public class Keyboard {
}
} else if (row == 8 && col == 4) {
if (shift) {
keyPressed(Key.NONE);
keyPressed(Key.PLUS_MINUS);
} else if (alpha) {
keyPressed(Key.NONE);
} else {
@ -484,7 +484,7 @@ public class Keyboard {
}
public static enum Key {
POWER, debug_DEG, debug_RAD, debug_GRA, SHIFT, ALPHA, NONE, HISTORY_BACK, HISTORY_FORWARD, DRG_CYCLE, LETTER_X, SIMPLIFY, SOLVE, BRIGHTNESS_CYCLE, BRIGHTNESS_CYCLE_REVERSE, DOT, NUM0, NUM1, NUM2, NUM3, NUM4, NUM5, NUM6, NUM7, NUM8, NUM9, PARENTHESIS_OPEN, PARENTHESIS_CLOSE, PLUS, MINUS, MULTIPLY, DIVIDE, EQUAL, DELETE, RESET, LEFT, RIGHT, UP, DOWN, OK, debug1, debug2, debug3, debug4, debug5, SQRT, ROOT, POWER_OF_2, POWER_OF_x
POWER, debug_DEG, debug_RAD, debug_GRA, SHIFT, ALPHA, NONE, HISTORY_BACK, HISTORY_FORWARD, DRG_CYCLE, LETTER_X, LETTER_Y, SIMPLIFY, SOLVE, BRIGHTNESS_CYCLE, BRIGHTNESS_CYCLE_REVERSE, DOT, NUM0, NUM1, NUM2, NUM3, NUM4, NUM5, NUM6, NUM7, NUM8, NUM9, PARENTHESIS_OPEN, PARENTHESIS_CLOSE, PLUS, MINUS, PLUS_MINUS, MULTIPLY, DIVIDE, EQUAL, DELETE, RESET, LEFT, RIGHT, UP, DOWN, OK, debug1, debug2, debug3, debug4, debug5, SQRT, ROOT, POWER_OF_2, POWER_OF_x
}
}
@ -527,7 +527,7 @@ public class Keyboard {
|5,8---|4,8---|3,8---|2,8---|1,8-----------------|
| 0 | . | | | SOLVE |
| | | | | SIMPLIFY |
| | | |DRGCYCL| |
| X | Y | Z |DRGCYCL| |
|------|------|------|------|--------------------|

View File

@ -88,6 +88,13 @@ public class PIFrame extends JFrame {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_Y:
if (Keyboard.alpha) {
Keyboard.keyPressed(Key.LETTER_Y);
} else {
Keyboard.keyPressed(Key.NONE);
}
break;
case KeyEvent.VK_B:
if (Keyboard.shift) {
Keyboard.keyPressed(Key.BRIGHTNESS_CYCLE_REVERSE);
@ -186,6 +193,8 @@ public class PIFrame extends JFrame {
case KeyEvent.VK_ADD:
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.PLUS);
} else if (Keyboard.shift) {
Keyboard.keyPressed(Key.PLUS_MINUS);
} else {
Keyboard.keyPressed(Key.NONE);
}

View File

@ -3,6 +3,8 @@ package org.warp.picalculator;
import static org.warp.engine.Display.Render.getStringWidth;
import static org.warp.engine.Display.Render.glDrawStringLeft;
import java.util.List;
import org.nevec.rjm.NumeroAvanzatoVec;
import org.warp.device.PIDisplay;
import org.warp.engine.Display;
@ -32,7 +34,16 @@ public abstract class AnteriorFunction implements Function {
public abstract String getSymbol();
@Override
public abstract Function solve() throws Error;
public abstract List<Function> solveOneStep() throws Error;
protected int stepsCount = -1;
@Override
public int getStepsCount() {
if (stepsCount == -1) {
stepsCount = variable.getStepsCount()+1;
}
return stepsCount;
}
@Override
public void generateGraphics() {
@ -77,11 +88,12 @@ public abstract class AnteriorFunction implements Function {
@Override
public String toString() {
try {
return solve().toString();
} catch (Error e) {
return e.id.toString();
}
// try {
// return solve().toString();
return "TODO: fare una nuova alternativa a solve().toString()";
// } catch (Error e) {
// return e.id.toString();
// }
}
@Override

View File

@ -3,6 +3,8 @@ package org.warp.picalculator;
import static org.warp.engine.Display.Render.getStringWidth;
import static org.warp.engine.Display.Render.glDrawStringLeft;
import java.util.List;
import org.nevec.rjm.NumeroAvanzatoVec;
import org.warp.device.PIDisplay;
import org.warp.engine.Display;
@ -32,7 +34,16 @@ public abstract class AnteriorFunctionBase extends FunctionBase {
public abstract String getSymbol();
@Override
public abstract Number solve() throws Error;
public abstract List<Function> solveOneStep() throws Error;
protected int stepsCount = -1;
@Override
public int getStepsCount() {
if (stepsCount == -1) {
stepsCount = variable.getStepsCount()+1;
}
return stepsCount;
}
@Override
public void generateGraphics() {
@ -77,11 +88,12 @@ public abstract class AnteriorFunctionBase extends FunctionBase {
@Override
public String toString() {
try {
return solve().toString();
} catch (Error e) {
return e.id.toString();
}
// try {
// return solve().toString();
return "TODO: fare una nuova alternativa a solve().toString()";
// } catch (Error e) {
// return e.id.toString();
// }
}
@Override

View File

@ -1,5 +1,9 @@
package org.warp.picalculator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.nevec.rjm.NumeroAvanzato;
import org.warp.device.PIDisplay;
import org.warp.engine.Screen;
@ -13,12 +17,6 @@ public class Calculator {
public static int currentSession = 0;
public static boolean haxMode = true;
public static Number solveResult(String string) throws Error {
System.out.println("INPUT: " + string);
Expression expression = new Expression(string);
return expression.solve();
}
public static Function parseString(String string) throws Error {
if (string.contains("{")) {
if (!string.startsWith("{")) {
@ -55,8 +53,29 @@ public class Calculator {
if (f instanceof Equation) {
PIDisplay.INSTANCE.setScreen(new SolveEquationScreen(es));
} else {
es.f2 = es.f.solve();
es.f2.generateGraphics();
List<Function> results = new ArrayList<>();
List<Function> partialResults = new ArrayList<>();
results.add(es.f);
while (Utils.allSolved(results) == false) {
for (Function itm : results) {
if (itm.getStepsCount() > 0) {
partialResults.addAll(itm.solveOneStep());
} else {
partialResults.add(itm);
}
}
results = new ArrayList<Function>(partialResults);
partialResults.clear();
}
if (results.size() == 0) {
} else {
Collections.reverse(results);
es.f2 = results;
for (Function rf : es.f2) {
rf.generateGraphics();
}
}
}
}
}
@ -66,8 +85,12 @@ public class Calculator {
EquationScreen es = (EquationScreen) Calculator.sessions[0];
Function f = es.f;
if (f instanceof Equation) {
es.f2 = ((Equation)f).solve(letter);
es.f2.generateGraphics();
List<Function> results = ((Equation)f).solve(letter);
Collections.reverse(results);
es.f2 = results;
for (Function rf : es.f2) {
rf.generateGraphics();
}
}
}
}

View File

@ -5,6 +5,9 @@ import static org.warp.engine.Display.Render.glColor3f;
import static org.warp.engine.Display.Render.glDrawStringLeft;
import static org.warp.engine.Display.Render.glFillRect;
import java.util.ArrayList;
import java.util.List;
import org.nevec.rjm.NumeroAvanzatoVec;
import org.warp.device.PIDisplay;
import org.warp.engine.Display;
@ -21,14 +24,53 @@ public class Division extends FunctionTwoValuesBase {
}
@Override
public Number solve() throws Error {
if (variable2 == null || variable1 == null) {
return new Number("0");
public List<Function> solveOneStep() throws Error {
if (variable1 == null || variable2 == null) {
throw new Error(Errors.SYNTAX_ERROR);
}
if (variable2.solve().getTerm().compareTo(NumeroAvanzatoVec.ZERO) == 0) {
ArrayList<Function> result = new ArrayList<>();
if (stepsCount == 1) {
if (variable2 instanceof Number && ((Number)variable2).getTerm().compareTo(NumeroAvanzatoVec.ZERO) == 0) {
throw new Error(Errors.DIVISION_BY_ZERO);
}
return variable1.solve().divide(variable2.solve());
result.add(((Number) variable1).divide((Number)variable2));
} else {
List<Function> l1 = new ArrayList<Function>();
List<Function> l2 = new ArrayList<Function>();
if (variable1.getStepsCount() >= stepsCount - 1) {
l1.addAll(variable1.solveOneStep());
} else {
l1.add(variable1);
}
if (variable2.getStepsCount() >= stepsCount - 1) {
l2.addAll(variable2.solveOneStep());
} else {
l2.add(variable2);
}
int size1 = l1.size();
int size2 = l2.size();
int cur1 = 0;
int cur2 = 0;
int total = l1.size()*l2.size();
Function[][] results = new Function[total][2];
for (int i = 0; i < total; i++) {
results[i] = new Function[]{l1.get(cur1), l2.get(cur2)};
if (size1 < size2 && cur2 % size1 == 0) {
cur2+=1;
}
if (size2 < size1 && cur1 % size2 == 0) {
cur1+=1;
}
if (cur1 >= size1) cur1 = 0;
if (cur2 >= size1) cur2 = 0;
}
for (Function[] f : results) {
result.add(new Division((FunctionBase)f[0], (FunctionBase)f[1]));
}
}
stepsCount=-1;
return result;
}
public boolean hasMinus() {

View File

@ -1,9 +1,13 @@
package org.warp.picalculator;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.nevec.rjm.NumeroAvanzatoVec;
import com.rits.cloning.Cloner;
public class Equation extends FunctionTwoValues {
@ -18,11 +22,71 @@ public class Equation extends FunctionTwoValues {
}
@Override
public Function solve() throws Error {
return new Equation(new Subtraction((FunctionBase)variable1.solve(), (FunctionBase)variable2.solve()).solve(), new Number("0"));
public List<Function> solveOneStep() throws Error {
if (variable1 == null || variable2 == null) {
throw new Error(Errors.SYNTAX_ERROR);
}
ArrayList<Function> result = new ArrayList<>();
if (stepsCount == 1) {
if (((Number)variable2).getTerm().isBigInteger(false) && ((Number)variable2).getTerm().toBigInteger(false).compareTo(new BigInteger("0")) == 0) {
result.add(this);
} else {
result.add(new Equation(new Subtraction((FunctionBase)variable1, (FunctionBase)variable2), new Number("0")));
}
} else {
List<Function> l1 = new ArrayList<Function>();
List<Function> l2 = new ArrayList<Function>();
if (variable1.getStepsCount() >= stepsCount - 1) {
l1.addAll(variable1.solveOneStep());
} else {
l1.add(variable1);
}
if (variable2.getStepsCount() >= stepsCount - 1) {
l2.addAll(variable2.solveOneStep());
} else {
l2.add(variable2);
}
public Function solve(char variableCharacter) {
int size1 = l1.size();
int size2 = l2.size();
int cur1 = 0;
int cur2 = 0;
int total = l1.size()*l2.size();
Function[][] results = new Function[total][2];
for (int i = 0; i < total; i++) {
results[i] = new Function[]{l1.get(cur1), l2.get(cur2)};
if (cur1 < cur2 && cur2 % size1 == 0) {
cur2+=1;
} else if (cur2 < cur1 && cur1 % size2 == 0) {
cur1+=1;
}
if (cur1 >= size1) cur1 = 0;
if (cur2 >= size1) cur2 = 0;
}
for (Function[] f : results) {
result.add(new Equation((FunctionBase)f[0], (FunctionBase)f[1]));
}
stepsCount=-1;
}
return result;
}
private int stepsCount = -1;
@Override
public int getStepsCount() {
if (stepsCount == -1) {
int val1 = variable1.getStepsCount();
int val2 = variable2.getStepsCount();
if (val1 > val2) {
stepsCount = val1+1;
} else {
stepsCount = val2+1;
}
}
return stepsCount;
}
public List<Function> solve(char variableCharacter) {
@SuppressWarnings("unused")
ArrayList<Equation> e;
//TODO: WORK IN PROGRESS.

View File

@ -2,6 +2,9 @@ package org.warp.picalculator;
import static org.warp.engine.Display.Render.glDrawLine;
import java.util.ArrayList;
import java.util.List;
public class EquationsSystem extends FunctionMultipleValues {
static final int spacing = 2;
@ -23,9 +26,14 @@ public class EquationsSystem extends FunctionMultipleValues {
}
@Override
public Function solve() throws NumberFormatException, Error {
public List<Function> solveOneStep() throws NumberFormatException, Error {
// TODO implementare il calcolo dei sistemi
return variables[0].solve();
if (stepsCount == 1) {
List<Function> l = new ArrayList<Function>();
l.add(variables[0]);
return l;
}
return variables[0].solveOneStep();
}
@Override

View File

@ -3,6 +3,8 @@ package org.warp.picalculator;
import static org.warp.engine.Display.Render.glColor3f;
import static org.warp.engine.Display.Render.glDrawLine;
import java.util.List;
public class EquationsSystemPart extends AnteriorFunction {
public EquationsSystemPart(Equation equazione) {
@ -15,9 +17,9 @@ public class EquationsSystemPart extends AnteriorFunction {
}
@Override
public Equation solve() throws NumberFormatException, Error {
public List<Function> solveOneStep() throws NumberFormatException, Error {
// TODO implementare il calcolo dei sistemi
return (Equation) variable.solve();
return variable.solveOneStep();
}
@Override

View File

@ -8,11 +8,11 @@ import static org.warp.picalculator.Utils.concat;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.nevec.rjm.NumeroAvanzato;
import org.nevec.rjm.NumeroAvanzatoVec;
public class Expression extends FunctionMultipleValuesBase {
@ -195,6 +195,9 @@ public class Expression extends FunctionMultipleValuesBase {
case MathematicalSymbols.SUM:
f = new Sum(null, null);
break;
case MathematicalSymbols.SUM_SUBTRACTION:
f = new SumSubtraction(null, null);
break;
case MathematicalSymbols.MULTIPLICATION:
f = new Multiplication(null, null);
break;
@ -396,7 +399,7 @@ public class Expression extends FunctionMultipleValuesBase {
if (funzioneTMP instanceof FunctionTwoValuesBase) {
if (step != "SN Functions") {
if (
(step == "sums" && (funzioneTMP instanceof Sum) == true && ((funzioneTMP instanceof AnteriorFunctionBase && ((AnteriorFunctionBase) funzioneTMP).variable == null) || (funzioneTMP instanceof FunctionTwoValuesBase && ((FunctionTwoValuesBase) funzioneTMP).variable1 == null && ((FunctionTwoValuesBase) funzioneTMP).variable2 == null) || (!(funzioneTMP instanceof AnteriorFunctionBase) && !(funzioneTMP instanceof FunctionTwoValuesBase))))
(step == "sums" && (funzioneTMP instanceof Sum || funzioneTMP instanceof SumSubtraction) == true && ((funzioneTMP instanceof AnteriorFunctionBase && ((AnteriorFunctionBase) funzioneTMP).variable == null) || (funzioneTMP instanceof FunctionTwoValuesBase && ((FunctionTwoValuesBase) funzioneTMP).variable1 == null && ((FunctionTwoValuesBase) funzioneTMP).variable2 == null) || (!(funzioneTMP instanceof AnteriorFunctionBase) && !(funzioneTMP instanceof FunctionTwoValuesBase))))
||
(
step.equals("prioritary multiplications")
@ -427,6 +430,8 @@ public class Expression extends FunctionMultipleValuesBase {
&&
(funzioneTMP instanceof Sum) == false
&&
(funzioneTMP instanceof SumSubtraction) == false
&&
(funzioneTMP instanceof Multiplication) == false
&&
(funzioneTMP instanceof PrioritaryMultiplication) == false
@ -471,13 +476,13 @@ public class Expression extends FunctionMultipleValuesBase {
Utils.debug.println(debugSpaces + " •Set variable to expression:" + funzioneTMP.getSymbol());
try {
Utils.debug.println(debugSpaces + " " + "var1=" + ((FunctionTwoValuesBase) funzioneTMP).getVariable1().solve());
Utils.debug.println(debugSpaces + " " + "var1=" + ((FunctionTwoValuesBase) funzioneTMP).getVariable1().toString());
} catch (NullPointerException ex2) {}
try {
Utils.debug.println(debugSpaces + " " + "var2=" + ((FunctionTwoValuesBase) funzioneTMP).getVariable2().solve());
Utils.debug.println(debugSpaces + " " + "var2=" + ((FunctionTwoValuesBase) funzioneTMP).getVariable2().toString());
} catch (NullPointerException ex2) {}
try {
Utils.debug.println(debugSpaces + " " + "(result)=" + ((FunctionTwoValuesBase) funzioneTMP).solve());
Utils.debug.println(debugSpaces + " " + "(result)=" + ((FunctionTwoValuesBase) funzioneTMP).toString());
} catch (NullPointerException ex2) {}
} else {
@ -502,7 +507,7 @@ public class Expression extends FunctionMultipleValuesBase {
oldFunctionsList.remove(i + 1);
Utils.debug.println(debugSpaces + " •Set variable to expression:" + funzioneTMP.getSymbol());
FunctionBase var = ((AnteriorFunctionBase) funzioneTMP).getVariable().solve();
FunctionBase var = ((AnteriorFunctionBase) funzioneTMP).getVariable();
if (var == null) {
Utils.debug.println(debugSpaces + " " + "var=null");
} else {
@ -535,7 +540,7 @@ public class Expression extends FunctionMultipleValuesBase {
}
Utils.debug.println(debugSpaces + "•Finished correcting classes.");
Number result = solve();
String result = toString();
Utils.debug.println(debugSpaces + "•Result:" + result);
}
}
@ -546,17 +551,39 @@ public class Expression extends FunctionMultipleValuesBase {
}
@Override
public Number solve() throws Error {
public List<Function> solveOneStep() throws Error {
List<Function> ret = new ArrayList<>();
if (variables.length == 0) {
return new Number("0");
stepsCount = -1;
return ret;
} else if (variables.length == 1) {
return (Number) variables[0].solve();
if (variables[0].getStepsCount() > 0) {
List<Function> l = variables[0].solveOneStep();
for (Function f : l) {
if (f instanceof Number) {
ret.add(f);
} else {
Number result = new Number("0");
for (Function f : variables) {
result = result.add((Number) f.solve());
ret.add(new Expression(new FunctionBase[]{(FunctionBase) f}));
}
return result;
}
stepsCount = -1;
return ret;
} else {
ret.add(variables[0]);
stepsCount = -1;
return ret;
}
} else {
for (Function f : variables) {
if (f.getStepsCount() >= stepsCount - 1) {
List<Function> partial = f.solveOneStep();
for (Function fnc : partial) {
ret.add(new Expression(new FunctionBase[]{(FunctionBase) fnc}));
}
}
}
stepsCount = -1;
return ret;
}
}

View File

@ -1,9 +1,13 @@
package org.warp.picalculator;
import java.util.List;
public interface Function {
public String getSymbol();
public Function solve() throws Error;
public int getStepsCount();
public List<Function> solveOneStep() throws Error;
public void generateGraphics();
@ -16,4 +20,10 @@ public interface Function {
public int getLine();
public void setSmall(boolean small);
@Override
public int hashCode();
@Override
public boolean equals(Object o);
}

View File

@ -1,12 +1,17 @@
package org.warp.picalculator;
import java.util.List;
public abstract class FunctionBase implements Function {
@Override
public abstract String getSymbol();
@Override
public abstract Number solve() throws Error;
public abstract int getStepsCount();
@Override
public abstract List<Function> solveOneStep() throws Error;
@Override
public abstract void generateGraphics();

View File

@ -62,19 +62,35 @@ public abstract class FunctionMultipleValues implements Function {
@Override
public abstract String getSymbol();
protected int stepsCount = -1;
@Override
public abstract Function solve() throws Error;
public int getStepsCount() {
if (stepsCount == -1) {
int max = 0;
int cur = 0;
for (Function f : variables) {
cur = f.getStepsCount();
if (max < cur) {
max = cur;
}
}
return max+1;
} else {
return stepsCount;
}
}
@Override
public abstract void generateGraphics();
@Override
public String toString() {
try {
return solve().toString();
} catch (Error e) {
return e.id.toString();
}
// try {
// return solve().toString();
return "TODO: fare una nuova alternativa a solve().toString()";
// } catch (Error e) {
// return e.id.toString();
// }
}
@Override

View File

@ -59,22 +59,38 @@ public abstract class FunctionMultipleValuesBase extends FunctionBase {
variables = Arrays.copyOf(variables, length);
}
protected int stepsCount = -1;
@Override
public abstract String getSymbol();
public int getStepsCount() {
if (stepsCount == -1) {
int max = 0;
int cur = 0;
for (Function f : variables) {
cur = f.getStepsCount();
if (max < cur) {
max = cur;
}
}
return max+1;
} else {
return stepsCount;
}
}
@Override
public abstract Number solve() throws Error;
public abstract String getSymbol();
@Override
public abstract void generateGraphics();
@Override
public String toString() {
try {
return solve().toString();
} catch (Error e) {
return e.id.toString();
}
// try {
// return solve().toString();
return "TODO: fare una nuova alternativa a solve().toString()";
// } catch (Error e) {
// return e.id.toString();
// }
}
@Override

View File

@ -3,6 +3,8 @@ package org.warp.picalculator;
import static org.warp.engine.Display.Render.getStringWidth;
import static org.warp.engine.Display.Render.glDrawStringLeft;
import java.util.List;
import org.nevec.rjm.Rational;
import org.warp.device.PIDisplay;
import org.warp.engine.Display;
@ -43,7 +45,10 @@ public abstract class FunctionTwoValues implements Function {
public abstract String getSymbol();
@Override
public abstract Function solve() throws Error;
public abstract int getStepsCount();
@Override
public abstract List<Function> solveOneStep() throws Error;
@Override
public void generateGraphics() {
@ -93,11 +98,12 @@ public abstract class FunctionTwoValues implements Function {
@Override
public String toString() {
try {
return solve().toString();
} catch (Error e) {
return e.id.toString();
}
// try {
// return solve().toString();
return "TODO: fare una nuova alternativa a solve().toString()";
// } catch (Error e) {
// return e.id.toString();
// }
}
@Override

View File

@ -3,6 +3,8 @@ package org.warp.picalculator;
import static org.warp.engine.Display.Render.getStringWidth;
import static org.warp.engine.Display.Render.glDrawStringLeft;
import java.util.List;
import org.nevec.rjm.Rational;
import org.warp.device.PIDisplay;
import org.warp.engine.Display;
@ -43,7 +45,7 @@ public abstract class FunctionTwoValuesBase extends FunctionBase {
public abstract String getSymbol();
@Override
public abstract Number solve() throws Error;
public abstract List<Function> solveOneStep() throws Error;
@Override
public void generateGraphics() {
@ -93,11 +95,12 @@ public abstract class FunctionTwoValuesBase extends FunctionBase {
@Override
public String toString() {
try {
return solve().toString();
} catch (Error e) {
return e.id.toString();
}
// try {
// return solve().toString();
return "TODO: fare una nuova alternativa a solve().toString()";
// } catch (Error e) {
// return e.id.toString();
// }
}
@Override
@ -139,4 +142,19 @@ public abstract class FunctionTwoValuesBase extends FunctionBase {
}
return tl.getLine();
}
protected int stepsCount = -1;
@Override
public int getStepsCount() {
if (stepsCount == -1) {
int val1 = variable1.getStepsCount();
int val2 = variable2.getStepsCount();
if (val1 > val2) {
stepsCount = val1+1;
} else {
stepsCount = val2+1;
}
}
return stepsCount;
}
}

View File

@ -4,6 +4,7 @@ import static org.warp.picalculator.Utils.concat;
public class MathematicalSymbols {
public static final String SUM = "+";
public static final String SUM_SUBTRACTION = "±";
public static final String SUBTRACTION = "-";
public static final String MULTIPLICATION = "*";
public static final String PRIORITARY_MULTIPLICATION = "";
@ -29,7 +30,7 @@ public class MathematicalSymbols {
}
public static final String[] signums(boolean withMultiplication, boolean withPrioritaryMultiplication) {
String[] ret = new String[] { SUM, DIVISION };
String[] ret = new String[] { SUM, SUM_SUBTRACTION, DIVISION };
if (withMultiplication) {
ret = Utils.add(ret, MULTIPLICATION);
}

View File

@ -1,6 +1,8 @@
package org.warp.picalculator;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
public class Multiplication extends FunctionTwoValuesBase {
@ -14,8 +16,49 @@ public class Multiplication extends FunctionTwoValuesBase {
}
@Override
public Number solve() throws Error {
return getVariable1().solve().multiply(getVariable2().solve());
public List<Function> solveOneStep() throws Error {
if (variable1 == null || variable2 == null) {
throw new Error(Errors.SYNTAX_ERROR);
}
ArrayList<Function> result = new ArrayList<>();
if (stepsCount == 1) {
result.add(((Number)variable1).multiply((Number)variable2));
} else {
List<Function> l1 = new ArrayList<Function>();
List<Function> l2 = new ArrayList<Function>();
if (variable1.getStepsCount() >= stepsCount - 1) {
l1.addAll(variable1.solveOneStep());
} else {
l1.add(variable1);
}
if (variable2.getStepsCount() >= stepsCount - 1) {
l2.addAll(variable2.solveOneStep());
} else {
l2.add(variable2);
}
int size1 = l1.size();
int size2 = l2.size();
int cur1 = 0;
int cur2 = 0;
int total = l1.size()*l2.size();
Function[][] results = new Function[total][2];
for (int i = 0; i < total; i++) {
results[i] = new Function[]{l1.get(cur1), l2.get(cur2)};
if (cur1 < cur2 && cur2 % size1 == 0) {
cur2+=1;
} else if (cur2 < cur1 && cur1 % size2 == 0) {
cur1+=1;
}
if (cur1 >= size1) cur1 = 0;
if (cur2 >= size1) cur2 = 0;
}
for (Function[] f : results) {
result.add(new Multiplication((FunctionBase)f[0], (FunctionBase)f[1]));
}
}
stepsCount=-1;
return result;
}
@Override

View File

@ -8,6 +8,8 @@ import static org.warp.engine.Display.Render.glFillRect;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
import java.util.ArrayList;
import java.util.List;
import org.nevec.rjm.BigDecimalMath;
import org.nevec.rjm.NumeroAvanzato;
@ -65,11 +67,6 @@ public class Number extends FunctionBase {
width = calcWidth();
}
@Override
public Number solve() {
return this;
}
@Override
public String getSymbol() {
return toString();
@ -386,6 +383,18 @@ public class Number extends FunctionBase {
this.small = small;
}
@Override
public int getStepsCount() {
return 0;
}
@Override
public List<Function> solveOneStep() throws Error {
List<Function> result = new ArrayList<>();
result.add(this);
return result;
}
/*
* @Override
* public void draw(int x, int y, Graphics g) {

View File

@ -1,5 +1,8 @@
package org.warp.picalculator;
import java.util.ArrayList;
import java.util.List;
public class Power extends FunctionTwoValuesBase {
public Power(FunctionBase value1, FunctionBase value2) {
@ -25,8 +28,49 @@ public class Power extends FunctionTwoValuesBase {
}
@Override
public Number solve() throws NumberFormatException, Error {
return getVariable1().solve().pow(getVariable2().solve());
public List<Function> solveOneStep() throws Error {
if (variable1 == null || variable2 == null) {
throw new Error(Errors.SYNTAX_ERROR);
}
ArrayList<Function> result = new ArrayList<>();
if (stepsCount == 1) {
result.add(((Number)variable1).pow((Number)variable2));
} else {
List<Function> l1 = new ArrayList<Function>();
List<Function> l2 = new ArrayList<Function>();
if (variable1.getStepsCount() >= stepsCount - 1) {
l1.addAll(variable1.solveOneStep());
} else {
l1.add(variable1);
}
if (variable2.getStepsCount() >= stepsCount - 1) {
l2.addAll(variable2.solveOneStep());
} else {
l2.add(variable2);
}
int size1 = l1.size();
int size2 = l2.size();
int cur1 = 0;
int cur2 = 0;
int total = l1.size()*l2.size();
Function[][] results = new Function[total][2];
for (int i = 0; i < total; i++) {
results[i] = new Function[]{l1.get(cur1), l2.get(cur2)};
if (cur1 < cur2 && cur2 % size1 == 0) {
cur2+=1;
} else if (cur2 < cur1 && cur1 % size2 == 0) {
cur1+=1;
}
if (cur1 >= size1) cur1 = 0;
if (cur2 >= size1) cur2 = 0;
}
for (Function[] f : results) {
result.add(new Power((FunctionBase)f[0], (FunctionBase)f[1]));
}
}
stepsCount=-1;
return result;
}
@Override

View File

@ -1,5 +1,8 @@
package org.warp.picalculator;
import java.util.ArrayList;
import java.util.List;
public class PrioritaryMultiplication extends FunctionTwoValuesBase {
public PrioritaryMultiplication(FunctionBase value1, FunctionBase value2) {
@ -12,8 +15,49 @@ public class PrioritaryMultiplication extends FunctionTwoValuesBase {
}
@Override
public Number solve() throws Error {
return getVariable1().solve().multiply(getVariable2().solve());
public List<Function> solveOneStep() throws Error {
if (variable1 == null || variable2 == null) {
throw new Error(Errors.SYNTAX_ERROR);
}
ArrayList<Function> result = new ArrayList<>();
if (stepsCount == 1) {
result.add(((Number)variable1).multiply((Number)variable2));
} else {
List<Function> l1 = new ArrayList<Function>();
List<Function> l2 = new ArrayList<Function>();
if (variable1.getStepsCount() >= stepsCount - 1) {
l1.addAll(variable1.solveOneStep());
} else {
l1.add(variable1);
}
if (variable2.getStepsCount() >= stepsCount - 1) {
l2.addAll(variable2.solveOneStep());
} else {
l2.add(variable2);
}
int size1 = l1.size();
int size2 = l2.size();
int cur1 = 0;
int cur2 = 0;
int total = l1.size()*l2.size();
Function[][] results = new Function[total][2];
for (int i = 0; i < total; i++) {
results[i] = new Function[]{l1.get(cur1), l2.get(cur2)};
if (cur1 < cur2 && cur2 % size1 == 0) {
cur2+=1;
} else if (cur2 < cur1 && cur1 % size2 == 0) {
cur1+=1;
}
if (cur1 >= size1) cur1 = 0;
if (cur2 >= size1) cur2 = 0;
}
for (Function[] f : results) {
result.add(new PrioritaryMultiplication((FunctionBase)f[0], (FunctionBase)f[1]));
}
}
stepsCount=-1;
return result;
}
@Override

View File

@ -2,6 +2,9 @@ package org.warp.picalculator;
import static org.warp.engine.Display.Render.glDrawLine;
import java.util.ArrayList;
import java.util.List;
import org.nevec.rjm.NumeroAvanzatoVec;
public class Root extends FunctionTwoValuesBase {
@ -29,10 +32,51 @@ public class Root extends FunctionTwoValuesBase {
}
@Override
public Number solve() throws NumberFormatException, Error {
public List<Function> solveOneStep() throws Error {
if (variable1 == null || variable2 == null) {
throw new Error(Errors.SYNTAX_ERROR);
}
ArrayList<Function> result = new ArrayList<>();
if (stepsCount == 1) {
Number exponent = new Number(NumeroAvanzatoVec.ONE);
exponent = exponent.divide(getVariable1().solve());
return getVariable2().solve().pow(exponent);
exponent = exponent.divide((Number) getVariable1());
result.add(((Number)variable1).pow(exponent));
} else {
List<Function> l1 = new ArrayList<Function>();
List<Function> l2 = new ArrayList<Function>();
if (variable1.getStepsCount() >= stepsCount - 1) {
l1.addAll(variable1.solveOneStep());
} else {
l1.add(variable1);
}
if (variable2.getStepsCount() >= stepsCount - 1) {
l2.addAll(variable2.solveOneStep());
} else {
l2.add(variable2);
}
int size1 = l1.size();
int size2 = l2.size();
int cur1 = 0;
int cur2 = 0;
int total = l1.size()*l2.size();
Function[][] results = new Function[total][2];
for (int i = 0; i < total; i++) {
results[i] = new Function[]{l1.get(cur1), l2.get(cur2)};
if (cur1 < cur2 && cur2 % size1 == 0) {
cur2+=1;
} else if (cur2 < cur1 && cur1 % size2 == 0) {
cur1+=1;
}
if (cur1 >= size1) cur1 = 0;
if (cur2 >= size1) cur2 = 0;
}
for (Function[] f : results) {
result.add(new Root((FunctionBase)f[0], (FunctionBase)f[1]));
}
}
stepsCount=-1;
return result;
}
@Override

View File

@ -1,5 +1,9 @@
package org.warp.picalculator;
import java.util.ArrayList;
import java.util.List;
import org.nevec.rjm.NumeroAvanzatoVec;
import org.nevec.rjm.Rational;
public class RootSquare extends AnteriorFunctionBase {
@ -24,11 +28,15 @@ public class RootSquare extends AnteriorFunctionBase {
}
@Override
public Number solve() throws Error {
public List<Function> solveOneStep() throws Error {
if (variable == null) {
throw new Error(Errors.SYNTAX_ERROR);
}
ArrayList<Function> result = new ArrayList<>();
if (stepsCount == 1) {
try {
Number result = getVariable().solve();
result = result.pow(new Number(new Rational(1, 2)));
return result;
Number var = (Number) getVariable();
result.add(var.pow(new Number(new Rational(1, 2))));
} catch(NullPointerException ex) {
throw new Error(Errors.ERROR);
} catch(NumberFormatException ex) {
@ -36,6 +44,20 @@ public class RootSquare extends AnteriorFunctionBase {
} catch(ArithmeticException ex) {
throw new Error(Errors.NUMBER_TOO_SMALL);
}
} else {
List<Function> l1 = new ArrayList<Function>();
if (variable.getStepsCount() >= stepsCount - 1) {
l1.addAll(variable.solveOneStep());
} else {
l1.add(variable);
}
for (Function f : l1) {
result.add(new RootSquare((FunctionBase)f));
}
}
stepsCount=-1;
return result;
}
@Override

View File

@ -1,5 +1,8 @@
package org.warp.picalculator;
import java.util.ArrayList;
import java.util.List;
public class Subtraction extends FunctionTwoValuesBase {
public Subtraction(FunctionBase value1, FunctionBase value2) {
@ -12,8 +15,49 @@ public class Subtraction extends FunctionTwoValuesBase {
}
@Override
public Number solve() throws Error {
return getVariable1().solve().add(getVariable2().solve().multiply(new Number("-1")));
public List<Function> solveOneStep() throws Error {
if (variable1 == null || variable2 == null) {
throw new Error(Errors.SYNTAX_ERROR);
}
ArrayList<Function> result = new ArrayList<>();
if (stepsCount == 1) {
result.add(((Number)variable1).add(((Number)variable2).multiply(new Number("-1"))));
} else {
List<Function> l1 = new ArrayList<Function>();
List<Function> l2 = new ArrayList<Function>();
if (variable1.getStepsCount() >= stepsCount - 1) {
l1.addAll(variable1.solveOneStep());
} else {
l1.add(variable1);
}
if (variable2.getStepsCount() >= stepsCount - 1) {
l2.addAll(variable2.solveOneStep());
} else {
l2.add(variable2);
}
int size1 = l1.size();
int size2 = l2.size();
int cur1 = 0;
int cur2 = 0;
int total = l1.size()*l2.size();
Function[][] results = new Function[total][2];
for (int i = 0; i < total; i++) {
results[i] = new Function[]{l1.get(cur1), l2.get(cur2)};
if (cur1 < cur2 && cur2 % size1 == 0) {
cur2+=1;
} else if (cur2 < cur1 && cur1 % size2 == 0) {
cur1+=1;
}
if (cur1 >= size1) cur1 = 0;
if (cur2 >= size1) cur2 = 0;
}
for (Function[] f : results) {
result.add(new Subtraction((FunctionBase)f[0], (FunctionBase)f[1]));
}
}
stepsCount=-1;
return result;
}
}

View File

@ -3,6 +3,9 @@ package org.warp.picalculator;
import static org.warp.engine.Display.Render.getStringWidth;
import static org.warp.engine.Display.Render.glDrawStringLeft;
import java.util.ArrayList;
import java.util.List;
import org.warp.device.PIDisplay;
import org.warp.engine.Display;
@ -18,10 +21,48 @@ public class Sum extends FunctionTwoValuesBase {
}
@Override
public Number solve() throws Error {
Number val1 = getVariable1().solve();
Number val2 = getVariable2().solve();
Number result = val1.add(val2);
public List<Function> solveOneStep() throws Error {
if (variable1 == null || variable2 == null) {
throw new Error(Errors.SYNTAX_ERROR);
}
ArrayList<Function> result = new ArrayList<>();
if (stepsCount == 1) {
result.add(((Number)variable1).add((Number)variable2));
} else {
List<Function> l1 = new ArrayList<Function>();
List<Function> l2 = new ArrayList<Function>();
if (variable1.getStepsCount() >= stepsCount - 1) {
l1.addAll(variable1.solveOneStep());
} else {
l1.add(variable1);
}
if (variable2.getStepsCount() >= stepsCount - 1) {
l2.addAll(variable2.solveOneStep());
} else {
l2.add(variable2);
}
int size1 = l1.size();
int size2 = l2.size();
int cur1 = 0;
int cur2 = 0;
int total = l1.size()*l2.size();
Function[][] results = new Function[total][2];
for (int i = 0; i < total; i++) {
results[i] = new Function[]{l1.get(cur1), l2.get(cur2)};
if (cur1 < cur2 && cur2 % size1 == 0) {
cur2+=1;
} else if (cur2 < cur1 && cur1 % size2 == 0) {
cur1+=1;
}
if (cur1 >= size1) cur1 = 0;
if (cur2 >= size1) cur2 = 0;
}
for (Function[] f : results) {
result.add(new Sum((FunctionBase)f[0], (FunctionBase)f[1]));
}
}
stepsCount=-1;
return result;
}

View File

@ -0,0 +1,117 @@
package org.warp.picalculator;
import static org.warp.engine.Display.Render.getStringWidth;
import static org.warp.engine.Display.Render.glDrawStringLeft;
import java.util.ArrayList;
import java.util.List;
import org.warp.device.PIDisplay;
import org.warp.engine.Display;
public class SumSubtraction extends FunctionTwoValuesBase {
public SumSubtraction(FunctionBase value1, FunctionBase value2) {
super(value1, value2);
}
@Override
public String getSymbol() {
return MathematicalSymbols.SUM_SUBTRACTION;
}
@Override
public List<Function> solveOneStep() throws Error {
if (variable1 == null || variable2 == null) {
throw new Error(Errors.SYNTAX_ERROR);
}
ArrayList<Function> result = new ArrayList<>();
if (stepsCount == 1) {
result.add(((Number)variable1).add((Number)variable2));
result.add(((Number)variable1).add(((Number)variable2).multiply(new Number("-1"))));
} else {
List<Function> l1 = new ArrayList<Function>();
List<Function> l2 = new ArrayList<Function>();
if (variable1.getStepsCount() >= stepsCount - 1) {
l1.addAll(variable1.solveOneStep());
} else {
l1.add(variable1);
}
if (variable2.getStepsCount() >= stepsCount - 1) {
l2.addAll(variable2.solveOneStep());
} else {
l2.add(variable2);
}
int size1 = l1.size();
int size2 = l2.size();
int cur1 = 0;
int cur2 = 0;
int total = l1.size()*l2.size();
Function[][] results = new Function[total][2];
for (int i = 0; i < total; i++) {
results[i] = new Function[]{l1.get(cur1), l2.get(cur2)};
if (cur1 < cur2 && cur2 % size1 == 0) {
cur2+=1;
} else if (cur2 < cur1 && cur1 % size2 == 0) {
cur1+=1;
}
if (cur1 >= size1) cur1 = 0;
if (cur2 >= size1) cur2 = 0;
}
for (Function[] f : results) {
result.add(new SumSubtraction((FunctionBase)f[0], (FunctionBase)f[1]));
}
}
stepsCount=-1;
return result;
}
@Override
public void generateGraphics() {
variable1.setSmall(small);
variable1.generateGraphics();
variable2.setSmall(small);
variable2.generateGraphics();
width = calcWidth();
height = calcHeight();
line = calcLine();
}
@Override
public void draw(int x, int y) {
// glColor3f(127, 127-50+new Random().nextInt(50), 255);
// glFillRect(x,y,width,height);
// glColor3f(0, 0, 0);
int ln = getLine();
int dx = 0;
variable1.draw(dx + x, ln - variable1.getLine() + y);
dx += variable1.getWidth();
if (small) {
Display.Render.setFont(PIDisplay.fonts[1]);
} else {
Display.Render.setFont(PIDisplay.fonts[0]);
}
dx += 1;
glDrawStringLeft(dx + x, ln - Utils.getFontHeight(small) / 2 + y, getSymbol());
dx += getStringWidth(getSymbol());
variable2.draw(dx + x, ln - variable2.getLine() + y);
}
@Override
public int getWidth() {
return width;
}
@Override
protected int calcWidth() {
int dx = 0;
dx += variable1.getWidth();
dx += 1;
dx += getStringWidth(getSymbol());
return dx += variable2.getWidth();
}
}

View File

@ -11,6 +11,7 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import org.nevec.rjm.BigDecimalMath;
import org.nevec.rjm.Rational;
@ -82,7 +83,7 @@ public class Utils {
public static boolean areThereOnlySettedUpFunctionsSumsEquationsAndSystems(ArrayList<Function> fl) {
for (int i = 0; i < fl.size(); i++) {
if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Sum || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) {
if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) {
if (fl.get(i) instanceof AnteriorFunctionBase) {
if (((AnteriorFunctionBase) fl.get(i)).variable == null) {
return false;
@ -101,7 +102,7 @@ public class Utils {
public static boolean areThereOnlySettedUpFunctionsSumsMultiplicationsEquationsAndSystems(ArrayList<Function> fl) {
for (int i = 0; i < fl.size(); i++) {
if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Multiplication || fl.get(i) instanceof PrioritaryMultiplication || fl.get(i) instanceof Sum || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) {
if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Multiplication || fl.get(i) instanceof PrioritaryMultiplication || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Equation || fl.get(i) instanceof EquationsSystemPart || fl.get(i) instanceof Expression)) {
if (fl.get(i) instanceof AnteriorFunctionBase) {
if (((AnteriorFunctionBase) fl.get(i)).variable == null) {
return false;
@ -169,7 +170,7 @@ public class Utils {
public static boolean areThereOnlyEmptyNSNFunctions(ArrayList<FunctionBase> fl) {
for (int i = 0; i < fl.size(); i++) {
if (fl.get(i) instanceof FunctionTwoValuesBase && !(fl.get(i) instanceof Sum) && !(fl.get(i) instanceof Subtraction) && !(fl.get(i) instanceof Multiplication) && !(fl.get(i) instanceof PrioritaryMultiplication) && !(fl.get(i) instanceof Division)) {
if (fl.get(i) instanceof FunctionTwoValuesBase && !(fl.get(i) instanceof Sum) && !(fl.get(i) instanceof SumSubtraction) && !(fl.get(i) instanceof Subtraction) && !(fl.get(i) instanceof Multiplication) && !(fl.get(i) instanceof PrioritaryMultiplication) && !(fl.get(i) instanceof Division)) {
if (((FunctionTwoValuesBase) fl.get(i)).variable1 == null && ((FunctionTwoValuesBase) fl.get(i)).variable2 == null) {
return true;
}
@ -203,7 +204,7 @@ public class Utils {
public static boolean areThereEmptySums(ArrayList<FunctionBase> fl) {
for (int i = 0; i < fl.size(); i++) {
if (fl.get(i) instanceof Sum) {
if (fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction) {
if (((FunctionTwoValuesBase) fl.get(i)).variable1 == null && ((FunctionTwoValuesBase) fl.get(i)).variable2 == null) {
return true;
}
@ -225,7 +226,7 @@ public class Utils {
public static boolean areThereOtherSettedUpFunctions(ArrayList<Function> fl) {
for (int i = 0; i < fl.size(); i++) {
if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Sum || fl.get(i) instanceof Expression || fl.get(i) instanceof AnteriorFunctionBase || fl.get(i) instanceof Multiplication || fl.get(i) instanceof PrioritaryMultiplication || fl.get(i) instanceof Division)) {
if (!(fl.get(i) instanceof Number || fl.get(i) instanceof Sum || fl.get(i) instanceof SumSubtraction || fl.get(i) instanceof Expression || fl.get(i) instanceof AnteriorFunctionBase || fl.get(i) instanceof Multiplication || fl.get(i) instanceof PrioritaryMultiplication || fl.get(i) instanceof Division)) {
if (fl.get(i) instanceof AnteriorFunctionBase) {
if (((AnteriorFunctionBase) fl.get(i)).variable == null) {
return true;
@ -382,4 +383,13 @@ public class Utils {
}
return realbytes;
}
public static boolean allSolved(List<Function> expressions) {
for (Function itm : expressions) {
if (itm.getStepsCount() > 0) {
return false;
}
}
return true;
}
}

View File

@ -4,6 +4,7 @@ import static org.warp.engine.Display.Render.*;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;
import org.warp.device.Keyboard.Key;
import org.warp.device.PIDisplay;
@ -24,7 +25,7 @@ public class EquationScreen extends Screen {
public volatile boolean showCaret = true;
public volatile float showCaretDelta = 0f;
public Function f;
public Function f2;
public List<Function> f2;
public int ew1;
public int ew2;
public int eh2;
@ -150,8 +151,13 @@ public class EquationScreen extends Screen {
glDrawStringLeft(2, 22, nuovaEquazione.substring(0, caretPos)+(showCaret?"|":"")+nuovaEquazione.substring(((showCaret==false||nuovaEquazione.length()<=caretPos)?caretPos:caretPos+1), nuovaEquazione.length()));
if (f != null)
f.draw(2, 22+1+9+1);
if (f2 != null)
f2.draw(Display.getWidth() - 2 - f2.getWidth(), Display.getHeight() - 2 - f2.getHeight());
if (f2 != null) {
int bottomSpacing = 0;
for (Function f : f2) {
bottomSpacing += f.getHeight()+2;
f.draw(Display.getWidth() - 2 - f.getWidth(), Display.getHeight() - bottomSpacing);
}
}
}
@Override
@ -184,6 +190,9 @@ public class EquationScreen extends Screen {
interpreta(nuovaEquazione);
solve();
} catch (Exception ex) {
if (Utils.debugOn) {
ex.printStackTrace();
}
throw new Error(Errors.ERROR);
}
} catch (Error e) {
@ -234,6 +243,9 @@ public class EquationScreen extends Screen {
case MINUS:
typeChar("-");
return true;
case PLUS_MINUS:
typeChar("±");
return true;
case MULTIPLY:
typeChar("*");
return true;
@ -265,6 +277,12 @@ public class EquationScreen extends Screen {
case POWER_OF_x:
typeChar("^");
return true;
case LETTER_X:
typeChar("X");
return true;
case LETTER_Y:
typeChar("Y");
return true;
case DELETE:
if (nuovaEquazione.length() > 0) {
if (caretPos > 0) {