Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit c9bfe35

Browse files
authored
Add files via upload
1 parent 11829c9 commit c9bfe35

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

debuggableapp.java

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import java.io.*;
2+
import java.util.*;
3+
class Var {
4+
private Object object;
5+
public Var() {
6+
this.object=null;
7+
}
8+
public Var(Object o) {
9+
this.object=o;
10+
}
11+
public void set(Object object) { this.object = object; }
12+
public Object get() { return object; }
13+
}
14+
public class debuggableapp {
15+
public static PrintWriter debug;
16+
public static HashMap<String,Var> db=new HashMap<String,Var>();
17+
public static void setup() {
18+
try {
19+
debug=new PrintWriter(new BufferedWriter(new FileWriter("programdebug.info")));
20+
}catch(Exception e) {
21+
e.printStackTrace();
22+
System.out.println("WARNING:Log file cannot be initliazed, redirecting to stdout! This may be a restrcited system!");
23+
debug=new PrintWriter(System.out);
24+
25+
}
26+
debug.println("Setup completed");
27+
}
28+
public static void session() {
29+
debug.println("Session started");
30+
System.out.println("Debug 1.0 Session\nPress enter to stop\nWarning timing this program will be messed up!");
31+
String text=">";
32+
Scanner sc=new Scanner(System.in);
33+
while(!(text.equals(""))) {
34+
System.out.print(">");
35+
text=sc.nextLine();
36+
if(db.containsKey(text)) {
37+
show(db.get(text));
38+
}
39+
}
40+
}
41+
public static void show(Var x) {
42+
debug.println(x.getClass());
43+
if(x.getClass().getName().contains((CharSequence) "List")) {
44+
System.out.println("WARNING this is a list");
45+
debug.println("WARNING this is a list");
46+
}
47+
System.out.println(x.get());
48+
}
49+
public static void add(Var x,String friendlyname) {
50+
db.put(friendlyname, x);
51+
}
52+
public static void set(Var x,String friendlyname) {
53+
db.put(friendlyname, x);
54+
55+
56+
57+
}
58+
public static void main(String[] args) {
59+
setup();
60+
String x="test";
61+
Var a=new Var("Testing");
62+
add(a,x);
63+
session();
64+
a.set("sync test");
65+
Var a2=new Var(new ArrayList<Integer>());
66+
add(a2,"arr");
67+
session();
68+
}
69+
70+
}

0 commit comments

Comments
 (0)