Esempio n. 1
0
        static async Task Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.WriteLine(args[0]);

            string teststring;
            string townstring;


            Console.WriteLine("do you want offline or online = off/on");
            teststring = Console.ReadLine();

            if (teststring == "off")
            {
                Console.WriteLine("What street are you looking for: ");
                townstring = Console.ReadLine();

                OfflineCityBikeDataFetcher offline = new OfflineCityBikeDataFetcher();

                try
                {
                    Console.WriteLine(await offline.GetBikeCountInStation(townstring));
                }

                catch (NotFoundException e)
                {
                    Console.WriteLine("Not Found " + e.Message);
                }
            }

            if (teststring == "on")
            {
                Console.WriteLine("What street are you looking for: ");
                townstring = Console.ReadLine();
                RealTimeCityBikeDataFetcher realTime = new RealTimeCityBikeDataFetcher();
                try
                {
                    Console.WriteLine(await realTime.GetBikeCountInStation(townstring));
                }
                catch (NotFoundException e)
                {
                    Console.WriteLine("Not Found " + e.Message);
                }
            }
            if (teststring != "off" && teststring != "on")
            {
                Console.WriteLine("wrote something else");
            }
        }
Esempio n. 2
0
        static async Task Main(string[] args)
        {
            if (args[0] == "realtime")
            {
                RealTimeCityBikeDataFetcher querier = new RealTimeCityBikeDataFetcher();
                Task <int> bikeamount = querier.GetBikeCountInStation(args[1]);
                Console.WriteLine("Waiting results");
                int result = await bikeamount;
            }

            else if (args[0] == "offline")
            {
                OfflineCityBikeDataFetcher OfflineQuery = new OfflineCityBikeDataFetcher();
                Task <int> bikeamount2 = OfflineQuery.GetBikeCountInStation(args[0]);
            }
        }
Esempio n. 3
0
        static async Task Main(string[] args)
        {
            int    bikeAmount = 0;
            string haku       = args[0];

            if (args.Length > 2)
            {
                for (int i = 1; i < args.Length - 1; i++)
                {
                    haku += " " + args[i];
                }
            }

            //Console.WriteLine(args[0]);

            OfflineCityBikeDataFetcher  offlinehaku = new OfflineCityBikeDataFetcher();
            RealTimeCityBikeDataFetcher nettihaku   = new RealTimeCityBikeDataFetcher();

            if (args[args.Length - 1] == "offline")
            {
                try{
                    bikeAmount = await offlinehaku.GetBikeCountInStation(haku);

                    Console.WriteLine("Täällä pyöriä onpi: " + bikeAmount);
                }
                catch (ArgumentException ex) {
                    Console.WriteLine("Invalid argument \n" + ex.Message);
                }
                catch (NotFoundException ex) {
                    Console.WriteLine("Not found: \n" + ex.Message);
                }
            }
            if (args[args.Length - 1] == "online")
            {
                try{
                    bikeAmount = await nettihaku.GetBikeCountInStation(haku);

                    Console.WriteLine("Täällä pyöriä onpi: " + bikeAmount);
                }
                catch (ArgumentException ex) {
                    Console.WriteLine("Invalid argument \n" + ex.Message);
                }
                catch (NotFoundException ex) {
                    Console.WriteLine("Not found: \n" + ex.Message);
                }
            }
        }