did some work on it, it should work in this config i think

This commit is contained in:
2024-09-08 01:01:39 +02:00
parent 09f5d17a59
commit 4a31cbc8d0
13 changed files with 288 additions and 19 deletions
+85
View File
@@ -0,0 +1,85 @@
// import java.lang.reflect.Method;
import java.util.*;
import a_utils.Stackitem;
import functions.ChangeHealth;
import a_utils.Player;
import operators.*;
public class entrypoint {
public static Stack<Stackitem<?>> S = new Stack<>();
public static Player player = new Player(20.0,20.0,200.0,200.0,1.0);
public static void main(String[] args){
// String[] args = {"2", "4", "2", "4", "2", "4", "+"};
for (int i = 0; i < args.length; i++) {
System.out.print(args[i] + " ");
}System.out.println();
for(int i = 0; i < args.length; i++){
try {
int numberval;
numberval = Integer.parseInt(args[i]);
S.push(new Stackitem<Double>("Double",(double)numberval));
}catch(Exception e){}
switch (args[i]) {
case "+":
new Plus(S);
break;
case "-":
new Minus(S);
break;
case "*":
new Multiply(S);
break;
case "/":
new Divide(S);
break;
case "p":
S.push(new Stackitem<Player>("Player",player));
break;
case "c":
new ChangeHealth(S);
break;
default:
break;
}
}
// for (int i = 0; i < args.length; i++) {
// System.out.println(args[i]);
// }
System.out.println("Stack size : " + S.size());
int size = S.size();
for (int o = 0; o < size; o++) {
switch(S.peek().type){
case "Double":
System.out.println(S.pop().value);
break;
case "Player":
Player p1 = (Player)S.pop().value;
System.out.println("Emily: \n - Health: " + p1.health + "/" + p1.maxHealth + "\n - Magicka: " + p1.magicka + "/" + p1.maxMagicka);
break;
}
}
// S.push(new Stackitem<Double>("Double",Double.parseDouble("4")));
// S.push(new Stackitem<Double>("Double",Double.parseDouble("2")));
}
}
// 18 * (8 + 2)