Esempio n. 1
0
 @Override
 public String execute(UserInterface userInterface) {
   userInterface.show("Your current experience is: " + character.getExperience());
   character.gainExperience(EXPERIENCE_TO_GAIN);
   userInterface.show("You gained " + EXPERIENCE_TO_GAIN + " through fighting!");
   return choices[0].getCode();
 }
Esempio n. 2
0
  /**
   * Executes the given Topic.
   *
   * @param topic the given topic to be executed, not null
   */
  public void execute(Topic topic) {
    userInterface.show(topic.getName());
    userInterface.show(topic.getNarration());
    Step currentStep = topic.getStartStep();
    userInterface.show(currentStep.getNarration());
    String userInput = currentStep.execute(userInterface);

    while (topic.hasNextStep(userInput, currentStep)) {
      currentStep = topic.getNextStep(userInput, currentStep);
      String narration = currentStep.getNarration();
      userInterface.show(narration);
      userInput = currentStep.execute(userInterface);
    }
    userInterface.show("Exiting the topic ....");
  }