Exemplo n.º 1
0
        public static void Main2(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Usage: SubwayTester [startStation] [endStation]");
                Environment.Exit(-1);
            }

            try
            {
                SubwayLoader loader = new SubwayLoader();
                Subway objectville = loader.LoadFromFile("ObjectvilleSubway.txt");

                if (!objectville.HasStation(args[0]))
                {
                    Console.WriteLine(args[0] + " is not a station in Objectville.");
                    Environment.Exit(-1);
                }
                else if (!objectville.HasStation(args[1]))
                {
                    Console.WriteLine(args[1] + " is not a station in Objectville.");
                    Environment.Exit(-1);
                }

                List<Connection> route = objectville.GetDirections(args[0], args[1]);
                SubwayPrinter printer = new SubwayPrinter();
                printer.PrintDirections(route);
            }
            catch (KeyNotFoundException e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 2
0
        public static void Main2(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("Usage: SubwayTester [startStation] [endStation]");
                Environment.Exit(-1);
            }

            try
            {
                SubwayLoader loader      = new SubwayLoader();
                Subway       objectville = loader.LoadFromFile("ObjectvilleSubway.txt");

                if (!objectville.HasStation(args[0]))
                {
                    Console.WriteLine(args[0] + " is not a station in Objectville.");
                    Environment.Exit(-1);
                }
                else if (!objectville.HasStation(args[1]))
                {
                    Console.WriteLine(args[1] + " is not a station in Objectville.");
                    Environment.Exit(-1);
                }

                List <Connection> route   = objectville.GetDirections(args[0], args[1]);
                SubwayPrinter     printer = new SubwayPrinter();
                printer.PrintDirections(route);
            }
            catch (KeyNotFoundException e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            try
            {
                SubwayLoader loader = new SubwayLoader();
                Subway objectville = loader.LoadFromFile("ObjectvilleSubway.txt");

                Console.WriteLine("Testing stations...");
                if (objectville.HasStation("Head First Lounge") &&
                        objectville.HasStation("Objectville Diner") &&
                        objectville.HasStation("Objectville Diner"))
                {
                    Console.WriteLine("... station test PASSED successfully.");
                }
                else
                {
                    Console.WriteLine("... station test FAILED.");
                    Environment.Exit(-1);
                }

                Console.WriteLine("\nTesting connections...");
                if (objectville.HasConnection("HeadFirstLabs", "LSP Lane", "Booch Line") &&
                    objectville.HasConnection("SRP Square", "OCP Orchard", "Liskov Line") &&
                    objectville.HasConnection("OOA&D Oval", "Head First Lounge", "Gamma Line"))
                {
                    Console.WriteLine("... conncetions test PASSED succesfully.");
                }
                else
                {
                    Console.WriteLine("... connections test FAILED.");
                    Environment.Exit(-1);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            try
            {
                SubwayLoader loader      = new SubwayLoader();
                Subway       objectville = loader.LoadFromFile("ObjectvilleSubway.txt");

                Console.WriteLine("Testing stations...");
                if (objectville.HasStation("Head First Lounge") &&
                    objectville.HasStation("Objectville Diner") &&
                    objectville.HasStation("Objectville Diner"))
                {
                    Console.WriteLine("... station test PASSED successfully.");
                }
                else
                {
                    Console.WriteLine("... station test FAILED.");
                    Environment.Exit(-1);
                }

                Console.WriteLine("\nTesting connections...");
                if (objectville.HasConnection("HeadFirstLabs", "LSP Lane", "Booch Line") &&
                    objectville.HasConnection("SRP Square", "OCP Orchard", "Liskov Line") &&
                    objectville.HasConnection("OOA&D Oval", "Head First Lounge", "Gamma Line"))
                {
                    Console.WriteLine("... conncetions test PASSED succesfully.");
                }
                else
                {
                    Console.WriteLine("... connections test FAILED.");
                    Environment.Exit(-1);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }