-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoom.java
More file actions
51 lines (51 loc) · 1.26 KB
/
Room.java
File metadata and controls
51 lines (51 loc) · 1.26 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
//Room.java
//Is Room Object, keeps track of the room name, room description, room options.
class Room{
public List options;
private int num_options;
private String description;
private String tag;
Room(){
options=new List();
num_options=0;
description="";
tag="";
}
public void insert_option(String txt){
//12 letters max for options (a-l)
if(num_options==12){ System.out.println("Error"); System.exit(0);}
//97=a in ascii, 98=b, etc
options.insert((Character.toString((char)(97+num_options))+". ").concat(txt),this);
num_options++;
}
public void addDescription(String txt){
if(txt==null) return;
else{
description=description.concat("\n"+txt+"\n");
}
}
public void addTag(String txt){
if(tag.length()==0 || tag==null){
//if theres no tag, then update it to txt
tag=txt;
}else{
//otherwise do nothing
return;
}
}
public void printDescription(){
System.out.println(this.description);
}
public String getTag(){
return tag;
}
public void print_options(){
System.out.println(description);
System.out.println("******************************************");
options.print();
System.out.println("******************************************");
}
public Room findOption(char z){
return(options.findOptionInfo(z));
}
}