package helloworld;

import java.util.function.Consumer;

import org.requirementsascode.UseCaseRunner;

public class HelloWorld04_EnterNameAndAgeExample extends AbstractHelloWorldExample{
	private static final Class<EnterText> ENTER_FIRST_NAME = EnterText.class;
	private static final Class<EnterText> ENTER_AGE = EnterText.class;
	
	private String firstName;
	private int age;
	
	public void start() {	
		UseCaseRunner useCaseRunner = new UseCaseRunner();
				
		useCaseRunner.useCaseModel().useCase("Get greeted")
			.basicFlow()
				.step("S1").system(promptUserToEnterFirstName())
				.step("S2").user(ENTER_FIRST_NAME).system(saveFirstName())
				.step("S3").system(promptUserToEnterAge())
				.step("S4").user(ENTER_AGE).system(saveAge())
				.step("S5").system(greetUserWithFirstNameAndAge())
				.step("S6").system(terminateApplication());
		
		useCaseRunner.run();
		
		useCaseRunner.reactTo(enterText());
		useCaseRunner.reactTo(enterText());
	}
	
	private Runnable promptUserToEnterFirstName() {
		return () -> System.out.print("Please enter your first name: ");
	}
	
	private Runnable promptUserToEnterAge() {
		return () -> System.out.print("Please enter your age: ");
	}

	private Consumer<EnterText> saveFirstName() {
		return enterTextEvent -> firstName = enterTextEvent.text;
	}
	
	private Consumer<EnterText> saveAge() {
		return enterTextEvent -> age = Integer.parseInt(enterTextEvent.text);
	}
	
	private Runnable greetUserWithFirstNameAndAge() {
		return () -> System.out.println("Hello, " + firstName + " (" + age + ").");
	}
	
	public static void main(String[] args){
		new HelloWorld04_EnterNameAndAgeExample().start();
	}
}

@@ -1240,29 +1240,24 @@
 rn enterText
-Event
  -%3E firstNam
@@ -1265,29 +1265,24 @@
  = enterText
-Event
 .text;%0A%09%7D%0A%09%0A
@@ -1340,21 +1340,16 @@
 nterText
-Event
  -%3E age 
@@ -1380,13 +1380,8 @@
 Text
-Event
 .tex

Rename "enterTextEvent" to "enterText"