Example #1
0
        public void AddVerbToObject(ref UserdefinedObject obj, string inputVerb)
        {
            UserdefinedVerb verb = new UserdefinedVerb(inputVerb);

            obj.Verbs.Add(verb);
            allVerbs.Add(verb);
        }
Example #2
0
        /*
         * private bool CheckIfTypeExistsInAllTypes(string inputType)
         * {
         *  foreach (var item in allTypes)
         *  {
         *      if (item.Name == inputType)
         *          return true;
         *  }
         *  return false;
         * }
         */

        public UserdefinedType GetTypeFromObject(UserdefinedObject obj, string inputType)
        {
            foreach (var item in obj.Types)
            {
                if (item.Name == inputType)
                {
                    return(item);
                }
            }
            return(null);
        }
Example #3
0
        public void CreateObject(string inputObject)
        {
            if (GetObjectFromAllObjects(inputObject) != null)
            {
                throw new Exception();
            }

            UserdefinedObject obj = new UserdefinedObject(inputObject);

            allObjects.Add(obj);
        }
Example #4
0
 public UserdefinedVerb GetVerbFromObject(UserdefinedObject obj, string inputVerb)
 {
     foreach (var item in obj.Verbs)
     {
         if (item.Name == inputVerb)
         {
             return(item);
         }
     }
     return(null);
 }
Example #5
0
        private void AddVerbToObject(string userInput)
        {
            string            inputObject = userInput.Split(' ')[0];
            string            inputVerb   = userInput.Split(' ')[2];
            UserdefinedObject obj         = dataStorage.GetObjectFromAllObjects(inputObject);

            if (obj != null)
            {
                UserdefinedVerb verbCheck = dataStorage.GetVerbFromObject(obj, inputVerb);
                if (verbCheck == null)
                {
                    dataStorage.AddVerbToObject(ref obj, inputVerb);
                    Console.WriteLine("The verb called {0} has been added to the object called {1}.", inputVerb, inputObject);
                }
                else // Refactor to catch exception instead
                {
                    Console.WriteLine("The verb you try to add to object {0} has already been added.", inputObject);
                }
            }
            else // Refactor to catch exception instead
            {
                Console.WriteLine("The object you try to define doesn't exist.");
            }
        }