forked from IF-LK-2020/rechenmaschine
+/- funktioniert
This commit is contained in:
@@ -182,9 +182,10 @@ public class Rechenmaschine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
result = 0;
|
|
||||||
|
|
||||||
tokenlist.toFirst();
|
tokenlist.toFirst();
|
||||||
|
result = Integer.parseInt(tokenlist.getContent().getToken());
|
||||||
|
|
||||||
while( tokenlist.hasAccess() ) {
|
while( tokenlist.hasAccess() ) {
|
||||||
Token currentToken = tokenlist.getContent();
|
Token currentToken = tokenlist.getContent();
|
||||||
|
|
||||||
@@ -192,11 +193,11 @@ public class Rechenmaschine {
|
|||||||
switch (currentToken.getToken()) {
|
switch (currentToken.getToken()) {
|
||||||
case "+":
|
case "+":
|
||||||
tokenlist.next();
|
tokenlist.next();
|
||||||
result += Integer.parseInt(currentToken.getToken());
|
result += Integer.parseInt(tokenlist.getContent().getToken());
|
||||||
break;
|
break;
|
||||||
case "-":
|
case "-":
|
||||||
tokenlist.next();
|
tokenlist.next();
|
||||||
result -= Integer.parseInt(currentToken.getToken());
|
result -= Integer.parseInt(tokenlist.getContent().getToken());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user