import java.util.Scanner;
public class NPCDialogue {
private String npcName;
private String[] dialogues;
public NPCDialogue(String name, String[] dialogues) {
this.npcName = name;
this.dialogues = dialogues;
}
public void startDialogue() {
System.out.println(npcName + ": " + dialogues[0]);
System.out.println("1: " + dialogues[1]);
System.out.println("2: " + dialogues[2]);
System.out.println("Выберите вариант (1 или 2):");
Scanner scanner = new Scanner(System.in);
int choice = scanner.nextInt();
if (choice == 1) {
System.out.println(npcName + ": " + dialogues[3]);
} else if (choice == 2) {
System.out.println(npcName + ": " + dialogues[4]);
} else {
System.out.println("Неверный выбор.");
}
}
public static void main(String[] args) {
String[] dialogues = {
"Привет, путник!",
"Как дела?",
"Что ты ищешь?",
"Я рад слышать это!",
"Надеюсь, ты найдешь то, что ищешь."
};
NPCDialogue npc = new NPCDialogue("Странник", dialogues);
npc.startDialogue();
}
}