コード例 #1
0
ファイル: Program.cs プロジェクト: leonidzats/CMTest
        static bool handleCommand(NetflixApp app, ref string user_id)
        {
            Console.WriteLine("content (c) , history (h) , exit (e) , switch user(s): ");
            var command = Console.ReadKey().KeyChar.ToString();

            Console.WriteLine();
            bool stop_execution = false;

            switch (command)
            {
            case "e":
            case "E":

                stop_execution = true;
                break;

            case "s":
            case "S":

                Console.WriteLine("swtching");
                Console.Write("user name: ");
                user_id = Console.ReadLine();
                app.login(user_id);

                break;

            case "h":
            case "H":
                Console.WriteLine($"user : {user_id}");
                var history_list = app.GetUserHistory(user_id);
                foreach (var entry in history_list)
                {
                    Console.WriteLine("\t" + entry);
                }
                break;

            case "c":
            case "C":
                Console.WriteLine("(1 – TV Show, 2 – Movie, 3 – Any)");
                var content_coice = Console.ReadKey().KeyChar;
                while (content_coice != '1' &&
                       content_coice != '2' &&
                       content_coice != '3')
                {
                    content_coice = Console.ReadKey().KeyChar;
                }
                Console.WriteLine();


                Watchable now_watching  = app.WatchSomething(user_id, content_coice.ToString());
                var       watching_done = 'n';
                while (watching_done != 'Y')
                {
                    Console.WriteLine($"now watching : {now_watching}");
                    Thread.Sleep(10 * 1000);
                    Console.WriteLine("R u done watching? (Y/n)");
                    watching_done = Console.ReadKey().KeyChar;
                }
                Console.WriteLine();
                Console.WriteLine($"thanks for watching :  {now_watching.title}");
                Console.WriteLine("please rank the content you just watched (0-10) :");
                float rank;
                while (!float.TryParse(Console.ReadLine(), out rank))
                {
                    Console.Clear();
                    Console.WriteLine("You entered an invalid rank");
                    Console.WriteLine("please rank the content you just watched (0-10):");
                }
                app.UpdateContentRank(user_id, now_watching, rank);
                Console.WriteLine("thank you for your input!!");
                break;
            }
            return(stop_execution);
        }