-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharacterObject.java
More file actions
106 lines (87 loc) · 2.27 KB
/
CharacterObject.java
File metadata and controls
106 lines (87 loc) · 2.27 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import java.util.Vector;
public class CharacterObject {
private String Name;
private Vector<Item> items = new Vector<Item>();
private String Description;
private Vector<String> Dialogue = new Vector<String>();
String solution = "", correctResponse = "", incorrectResponse = "";
Boolean givesStuff = false;
private Location existHere = new Location();
public CharacterObject() {
this.Name = new String();
this.Description = new String();
this.Dialogue.clear();
}
public CharacterObject(String Name) {
this.Name = Name;
this.Description = new String();
this.Dialogue.clear();
}
public CharacterObject(String Name, String Description) {
this.Name = Name;
this.Description = Description;
this.Dialogue.clear();
}
public String toString() {
return this.Name;
}
public String getName() {
return this.Name;
}
public void setName(String Name) {
this.Name = Name;
}
public void setLocation(Location l){
existHere = l;
}
public Location getLocation(){
return existHere;
}
public String getDescription(){
return this.Description;
}
public void setDescription(String Description) {
this.Description = Description;
}
public Vector<String> getDialogues() {
return (Vector<String>)this.Dialogue.clone();
}
public void addDialogue(String dialogue) {
this.Dialogue.addElement(dialogue);
}
public void removeDialogue(String dialogue) {
if(this.Dialogue.contains(dialogue))
this.Dialogue.removeElement(dialogue);
}
public Vector<Item> getItems() {
return (Vector<Item>)this.items.clone();
}
public void addItem(Item item) {
this.items.addElement(item);
}
public void removeItem(Item item) {
if(this.items.contains(item))
this.items.removeElement(item);
}
public void setSolution(String sol){
this.solution = sol;
}
public void setCorrectResponse(String corr){
this.correctResponse = corr;
}
public void setInCorrectResponse(String wrong) {
this.incorrectResponse = wrong;
}
public Boolean answerLookingFor(String answer) {
if(answer.contains(solution)) {
System.out.println(correctResponse);
if(!(this.items.isEmpty()))
System.out.println("You have received " +items.elementAt(0).toString());
return true;
}
else {
System.out.println(incorrectResponse);
return false;
}
}
}