示例#1
0
        private void RunTheClient()
        {
            IResponse         theResponse = new GenericResponse(false);
            REQUEST_TYPE_ENUM sendThis;

            while (connected)
            {
                OutputClientInfo();
                Console.WriteLine("\nPlease select an option:");
                if (youHaveTheStock)
                {
                    sendThis = StockholderOptions();
                }
                else
                {
                    sendThis = StocklessOptions();
                }

                switch (sendThis)
                {
                case REQUEST_TYPE_ENUM.SEND_INFO:
                    Console.WriteLine("Requesting updated market info. Please wait for the market to update.");
                    theResponse = theConnection.GetInfo();
                    break;

                case REQUEST_TYPE_ENUM.SEND_TRADE:
                    Console.WriteLine("Please enter the ID of the trader you want to give the stock to.");
                    string sendTo = Console.ReadLine();
                    Console.WriteLine($"Sending stock to {sendTo}");
                    theResponse = theConnection.GiveStock(sendTo);
                    break;

                case REQUEST_TYPE_ENUM.SEND_QUIT:
                    Console.WriteLine("bye");
                    connected = false;
                    break;
                }

                if (connected)
                {
                    marketInfo = theResponse.GetMarket();
                    Console.WriteLine(theResponse.GetInfo());
                }
            }
            theConnection.Dispose();
            Console.WriteLine("That's all, folks!");
        }