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\n Press enter to stop\n Warning 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+ System .out .println (x .get ());
44+ }
45+ public static void add (Var x ,String friendlyname ) {
46+ db .put (friendlyname , x );
47+ }
48+ public static void set (Var x ,String friendlyname ) {
49+ db .put (friendlyname , x );
50+ }
51+ public static void main (String [] args ) {
52+ setup ();
53+ String x ="test" ;
54+ Var a =new Var ("Testing" );
55+ add (a ,x );
56+ session ();
57+ a .set ("sync test" );
58+ Var a2 =new Var (new ArrayList <Integer >());
59+ add (a2 ,"arr" );
60+ session ();
61+ }
62+
63+ }
0 commit comments