Example #1
0
        static void Main(string[] args)
        {
            Sheep      sheep      = new Sheep();
            TextReader textReader = new TextReader();
            string     path       = @"C:\Users\pepij\Downloads\Programmeeruitdaging_SchaapjePluus\Input_SchaapjePluus.txt";

            Console.WriteLine("Do you want to use the testcase file? (Type 'y' to confirm)");
            if (Console.ReadLine() == "y")
            {
                if (File.Exists(path))
                {
                    Console.Write(textReader.StartTest());
                }
                else
                {
                    Console.WriteLine("No file found, exiting");
                }
            }
            else
            {
                Console.WriteLine("Enter the number you want to try:");
                string input = Console.ReadLine();
                Console.WriteLine(sheep.StartProgram(input));
            }
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
Example #2
0
        private string GetAnswer(string[] data)
        {
            Sheep         sheep          = new Sheep();
            string        Answer         = "";
            int           caseNumber     = 1;
            List <string> answers        = new List <string>();
            List <string> dataStringList = data.ToList <string>();
            List <int>    dataList       = new List <int>();

            foreach (string item in dataStringList)
            {
                int newItem = Int32.Parse(item);
                dataList.Add(newItem);
            }
            dataList.RemoveAt(0);

            foreach (int test in dataList)
            {
                string sheepAnswer = sheep.StartTest(test);
                answers.Add("Testcase #" + caseNumber + "= " + sheepAnswer + "\n");
                caseNumber++;
            }

            foreach (string answer in answers)
            {
                Answer += answer;
            }

            return(Answer);
        }