Пример #1
0
        public static bool AddInstanceVariable(Variable variable)
        {
            if (instance == null)
            {
                instance = new ArrayList();
            }

            Variable old = GetVariable(instance, variable.Name);
            if (old == null)
            {
                instance.Add(variable);
                return true;
            }
            else
            {
                return false;
            }
        }
Пример #2
0
        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            ClassInfo ci = new ClassInfo();
            ci.FileName = "HelloWorldExample.java";
            ci.ClassName = "HelloWorldExample";
            ci.Access = "public";
            ci.Type = "class";

            Method m = new Method();
            m.Name = "main";
            m.Access = "public";
            m.Attributes = new String[1] { "static" };
            m.ReturnType = "void";

            Variable v = new Variable();
            v.Name = "args";
            v.Type = "String[]";//edit dimension here

            m.AddParameter(v);
            m.Code = "System.out.println(\"Hello World!\");";
            ci.AddMethod(m);
            InsertTemplate(ci);
        }
Пример #3
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            NewClass nc = new NewClass(tabControl2.SelectedTab.Name);
            nc.ShowDialog();
            if (nc.Successful)
            {
                ClassInfo ci = new ClassInfo();
                ci.FileName = nc.Contents + ".java";
                ci.ClassName = nc.Contents;
                ci.Access = "public";
                ci.Type = "class";

                if (nc.HasConstructor)
                {
                    Method m = new Method();
                    m.Name = ci.ClassName;
                    m.Access = "public";
                    ci.AddMethod(m);
                }
                if (nc.HasMain)
                {
                    Method m = new Method();
                    m.Name = "main";
                    m.Access = "public";
                    m.Attributes = new String[1] { "static" };
                    m.ReturnType = "void";

                    Variable v = new Variable();
                    v.Name = "args";
                    v.Type = "String[]";        //edit dimension here
                    v.Method = m.Name;
                    m.AddParameter(v);
                    ci.AddMethod(m);
                }
                InsertTemplate(ci);
            }
        }
Пример #4
0
 public Boolean RemoveinstanceVariable(Variable v)
 {
     if (instanceVar.Contains(v))
     {
         instanceVar.Remove(v);
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #5
0
 public Boolean ContainsinstanceVariable(Variable v)
 {
     return instanceVar.Contains(v);
 }
Пример #6
0
 public void AddInstanceVariable(Variable v)
 {
     Variable old = GetinstanceVariable(v.Name);
     if (old != null)
     {
         RemoveinstanceVariable(old);
     }
     instanceVar.Add(v);
 }
Пример #7
0
 public Boolean RemoveVariable(Variable v)
 {
     if (variables.Contains(v))
     {
         variables.Remove(v);
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #8
0
 public Boolean ContainsVariable(Variable v)
 {
     return variables.Contains(v);
 }
Пример #9
0
 public void AddVariable(Variable v)
 {
     Variable old = GetVariable(v.Name);
     if (old != null)
     {
         RemoveVariable(old);
     }
     variables.Add(v);
 }
Пример #10
0
 public void AddParameter(Variable v)
 {
     parameters.Add(v);
 }
Пример #11
0
 public static void AddLocalVariable(Variable variable)
 {
     Variable old = GetVariable(local, variable.Name);
     if (old != null)
     {
         RemoveLocalVariable(old);
     }
     local.Add(variable);
 }
Пример #12
0
 public static Boolean RemoveLocalVariable(Variable variable)
 {
     if (local.Contains(variable))
     {
         local.Remove(variable);
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #13
0
 public static Boolean RemoveInstanceVariable(Variable variable)
 {
     if (instance.Contains(variable))
     {
         instance.Remove(variable);
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #14
0
        public static void InitializeContents()
        {
            instance = new ArrayList();
            local = new ArrayList();
            classes = new ArrayList();
            ci = new ClassInfo();
            m = new Method();

            ci.ClassName = "Object";
            m.Name = "toString";
            m.Access = "public";
            m.Attributes = null;
            m.ReturnType = "String";
            m.Parameters = new ArrayList();
            ci.AddMethod(m);
            classes.Add(ci);

            ci = new ClassInfo();
            ci.ClassName = "Character";
            m = new Method();
            m.Name = "isUpperCase";
            m.Access = "public";
            m.Attributes = new String[1]{"static"};
            m.ReturnType = "boolean";
            m.Parameters = new ArrayList();
            v = new Variable();
            v.Name = "ch";
            v.Type = "char";
            m.Parameters.Add(v);
            ci.AddMethod(m);

            m = new Method();
            m.Name = "isDigit";
            m.Access = "public";
            m.Attributes = new String[1]{"static"};
            m.ReturnType = "boolean";
            m.Parameters = new ArrayList();
            v = new Variable();
            v.Name = "ch";
            v.Type = "char";
            m.Parameters.Add(v);
            ci.AddMethod(m);
            classes.Add(ci);
        }
Пример #15
0
 public static Boolean ContainsInstanceVariable(Variable variable)
 {
     return instance.Contains(variable);
 }
Пример #16
0
 private bool IsNumeric(Variable v)
 {
     return v.Type == "byte" || v.Type == "double" || v.Type == "float" || v.Type == "int" || v.Type == "long" || v.Type == "short";
 }