itmo-prog-lab-3/src/characters/Child.java

49 lines
1.8 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package characters;
import enums.CharacterType;
import java.util.List;
public class Child extends Character {
String thoughts = "";
public Child(String name) {
super(CharacterType.CHILD, name);
}
// Child can listen to stories about the city and ask questions about the subject of the story
public void think(String story) {
if (story.contains("город")) {
this.thoughts += "Я никогда не был в городе, но история о " + context.getStoryContext() + " мне очень понравилась\n";
} else if (story.contains("путешествие")) {
this.thoughts += "Не люблю я путешествовать, но история о " + context.getStoryContext() + " мне очень понравилась\n";
}
else {
this.thoughts += "Интересная получается история о " + context.getStoryContext() + "\n";
}
}
public String converse(String subject) {
String response = this.name + " слушает историю о " + context.getStoryContext() + " и спрашивает вопросы о " + subject;
this.thoughts = "";
return response;
}
@Override
public String listen(String subject) {
String response = this.name + " слушает историю о " + context.getStoryContext() + " и спрашивает вопросы о " + subject;
this.thoughts = "";
return response;
}
public void discussTravelers(List<Traveler> travelers){
System.out.println(this.name + " обсуждает путешественников: ");
for(Traveler t: travelers){
if(t.isHome()){
System.out.println(t.getName());
}
}
}
}