diff --git a/src/main/java/com/example/Actor.java b/src/main/java/com/example/Actor.java index 0cac934..a846e7d 100644 --- a/src/main/java/com/example/Actor.java +++ b/src/main/java/com/example/Actor.java @@ -14,14 +14,13 @@ public class Actor extends AbstractBehavior { public record StartMessage(Expression expression) implements Message{} - private Actor(ActorContext context, String name, Expression expression){ + private Actor(ActorContext context, String name){ super(context); this.name = name; - this.expression = expression; } - public static Behavior create(String name,Expression expression){ - return Behaviors.setup(context -> new Actor(context, name, expression)); + public static Behavior create(String name){ + return Behaviors.setup(context -> new Actor(context, name)); } @Override @@ -33,7 +32,11 @@ public class Actor extends AbstractBehavior { private Behavior onStartMessage(StartMessage message){ this.expression = message.expression; + //Wenn initial nur Val übergeben wird -> einfach ausgeben + if(expression instanceof Expression.Val){ + System.out.println(((Expression.Val) expression).inner()); + } return this; } } diff --git a/src/main/java/com/example/AkkaMainSystem.java b/src/main/java/com/example/AkkaMainSystem.java index 946c2f2..d27ef68 100644 --- a/src/main/java/com/example/AkkaMainSystem.java +++ b/src/main/java/com/example/AkkaMainSystem.java @@ -32,9 +32,10 @@ public class AkkaMainSystem extends AbstractBehavior { //#create-actors Expression expression = Expression.generateExpression(6, 9); - ActorRef test = this.getContext().spawn(Actor.create("Seng", expression), "Sengmann"); - - System.out.println(expression.toString()+ " Wert:" +expression.eval()); + Expression testExp = Expression.generateExpression(1,9); + ActorRef test = this.getContext().spawn(Actor.create("Seng"), "Sengmann"); + test.tell(new Actor.StartMessage(testExp)); + System.out.println(testExp.toString()+ " Wert:" +expression.eval()); return this; } }