-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterpreterArrayDataType.java
More file actions
74 lines (61 loc) · 1.82 KB
/
InterpreterArrayDataType.java
File metadata and controls
74 lines (61 loc) · 1.82 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
package icsi311;
import java.util.HashMap;
public class InterpreterArrayDataType extends InterpreterDataType{
private HashMap<String, InterpreterDataType> storage;
private boolean isNumeric = false;
public InterpreterArrayDataType(){
storage = new HashMap<String, InterpreterDataType>();
}
public void put(String s){
int size = storage.size();
String key = String.valueOf(size);
storage.put(key, new InterpreterDataType(s));
if(isNumeric == false)
isNumeric = true;
}
public void putKey(String s){
storage.put(s, new InterpreterDataType(s));
}
public void put(InterpreterDataType i){
}
public InterpreterDataType get(String s){
return storage.get(s);
}
public String toString(){
if(isNumeric == true){
String fin = "(";
for(int i = 0; i < storage.size(); i++){
fin += storage.get(String.valueOf(i)).toString() + ",";
}
fin = fin.substring(0,fin.length()-1);
return fin + ")";}
return storage.toString();
}
public String printValue(){
String fin = "";
for(int i = 0; i < storage.size(); i++)
fin += storage.get(String.valueOf(i)).toString();
return fin;
}
public boolean containsVal(String s){
if(storage.containsKey(s))
return true;
return false;
}
public boolean containsKey(String s){
if(storage.containsKey(s))
return true;
return false;
}
public void removeKey(String s){
for(String n : storage.keySet()){
if(storage.get(n).toString().equals(s.toString())){
storage.remove(n);
break;
}
}
}
public HashMap<String, InterpreterDataType> getContent(){
return storage;
}
}