This repository was archived by the owner on Feb 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebuggableapp.java
70 lines (65 loc) · 1.86 KB
/
debuggableapp.java
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
import java.io.*;
import java.util.*;
class Var {
private Object object;
public Var() {
this.object=null;
}
public Var(Object o) {
this.object=o;
}
public void set(Object object) { this.object = object; }
public Object get() { return object; }
}
public class debuggableapp {
public static PrintWriter debug;
public static HashMap<String,Var> db=new HashMap<String,Var>();
public static void setup() {
try {
debug=new PrintWriter(new BufferedWriter(new FileWriter("programdebug.info")));
}catch(Exception e) {
e.printStackTrace();
System.out.println("WARNING:Log file cannot be initliazed, redirecting to stdout! This may be a restrcited system!");
debug=new PrintWriter(System.out);
}
debug.println("Setup completed");
}
public static void session() {
debug.println("Session started");
System.out.println("Debug 1.0 Session\nPress enter to stop\nWarning timing this program will be messed up!");
String text=">";
Scanner sc=new Scanner(System.in);
while(!(text.equals(""))) {
System.out.print(">");
text=sc.nextLine();
if(db.containsKey(text)) {
show(db.get(text));
}
}
}
public static void show(Var x) {
debug.println(x.getClass());
if(x.getClass().getName().contains((CharSequence) "List")) {
System.out.println("WARNING this is a list");
debug.println("WARNING this is a list");
}
System.out.println(x.get());
}
public static void add(Var x,String friendlyname) {
db.put(friendlyname, x);
}
public static void set(Var x,String friendlyname) {
db.put(friendlyname, x);
}
public static void main(String[] args) {
setup();
String x="test";
Var a=new Var("Testing");
add(a,x);
session();
a.set("sync test");
Var a2=new Var(new ArrayList<Integer>());
add(a2,"arr");
session();
}
}