예제 #1
0
        static void Main(string[] args)
        {
            if (!System.Console.IsOutputRedirected)
            {
                System.Console.Clear();
            }

            WriteBanner();

            System.Console.WriteLine("\nType exit or quit to terminate");
            System.Console.WriteLine("Type demo to run a demo\n");
            string[] exitCommands = new string[] { "quit", "exit" };

            IGalaxyEngine engine   = new GalaxyEngine();
            string        sentence = "";
            string        response = "";

            while (true)
            {
                try
                {
                    System.Console.Write(PROMPT);
                    sentence = Console.ReadLine();

                    if (exitCommands.Contains(sentence))
                    {
                        WriteResponseMessage("bye");
                        break;
                    }
                    else if (sentence == "demo")
                    {
                        Demo();
                    }
                    else if (sentence != "")
                    {
                        response = engine.Evaluate(sentence);
                        WriteResponseMessage(response);
                    }
                }
                catch (System.Exception ex)
                {
                    WriteException(ex);
                }
            }

            return;
        }
예제 #2
0
        private static void Demo()
        {
            IGalaxyEngine engine = new GalaxyEngine();

            string response = "";
            string sentence = "";

            sentence = "glob means I";
            System.Console.WriteLine(PROMPT + sentence);
            response = engine.Evaluate(sentence);
            WriteResponseMessage(response);

            sentence = "prok means V";
            System.Console.WriteLine(PROMPT + sentence);
            response = engine.Evaluate(sentence);
            WriteResponseMessage(response);

            sentence = "pish means X";
            System.Console.WriteLine(PROMPT + sentence);
            response = engine.Evaluate(sentence);
            WriteResponseMessage(response);

            sentence = "tegj means L";
            System.Console.WriteLine(PROMPT + sentence);
            response = engine.Evaluate(sentence);
            WriteResponseMessage(response);

            sentence = "glob glob units of Silver are worth 34 Credits";
            System.Console.WriteLine(PROMPT + sentence);
            response = engine.Evaluate(sentence);
            WriteResponseMessage(response);

            sentence = "glob prok units of Gold are worth 57800 Credits";
            System.Console.WriteLine(PROMPT + sentence);
            response = engine.Evaluate(sentence);
            WriteResponseMessage(response);

            sentence = "pish pish units of Iron are worth 3910 Credits";
            System.Console.WriteLine(PROMPT + sentence);
            response = engine.Evaluate(sentence);
            WriteResponseMessage(response);

            sentence = "how much is pish tegj glob glob ?";
            System.Console.WriteLine(PROMPT + sentence);
            response = engine.Evaluate(sentence);
            WriteResponseMessage(response);

            sentence = "how many Credits is glob prok Silver ?";
            System.Console.WriteLine(PROMPT + sentence);
            response = engine.Evaluate(sentence);
            WriteResponseMessage(response);

            sentence = "how many Credits is glob prok Gold ?";
            System.Console.WriteLine(PROMPT + sentence);
            response = engine.Evaluate(sentence);
            WriteResponseMessage(response);

            sentence = "how many Credits is glob prok Iron ?";
            System.Console.WriteLine(PROMPT + sentence);
            response = engine.Evaluate(sentence);
            WriteResponseMessage(response);

            sentence = "how much wood could a woodchuck chuck if a woodchuck could chuck wood ?";
            System.Console.WriteLine(PROMPT + sentence);
            response = engine.Evaluate(sentence);
            WriteResponseMessage(response);
        }