-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNPC.java
More file actions
50 lines (41 loc) · 1.16 KB
/
Copy pathNPC.java
File metadata and controls
50 lines (41 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.*;
public class NPC {
private String name;
private Map<String, String> dialogues;
private int order;
public NPC(String name, int order) {
this.name = name;
this.order = order;
this.dialogues = new HashMap<>();
}
public String getName() {
return this.name;
}
public void addDialogue(String key, String dialogue) {
dialogues.put(key, dialogue);
}
public int getDialogueOptions() {
int count = 1;
for (String option : dialogues.keySet()) {
System.out.println(count + ": " + option);
count++;
}
return count;
}
public void speak(String key) {
if (dialogues.get(key) != null) {
System.out.println(this.name + ": " + dialogues.get(key));
} else {
System.out.println("Invalid dialogue option, try again.");
}
}
public String toString() {
return this.name;
}
public Map<String, String> getDialogues() {
return this.dialogues;
}
public int getOrder() {
return this.order;
}
}