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

            obj.Verbs.Add(verb);
            allVerbs.Add(verb);
        }
Beispiel #2
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.");
            }
        }