Example #1
0
        public int PopulateChosenTopic(int x)
        {
            Console.Clear();
            Console.WriteLine($"You have chosen: {MyStoreTopics[x-1]}");
            List <Stock> activeList = MyStock[MyStoreTopics[x - 1]];
            Stock        activeItem;

            if (activeList.Count > 0)
            {
                Console.WriteLine();
                for (int i = 0; i < activeList.Count; i++)
                {
                    activeItem = activeList[i];
                    Console.WriteLine($"{i+1}. {activeItem.GetName()} --- {activeItem.GetDescription()}  ---- Price: {activeItem.GetPrice()}");
                }
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("There are no items for sale in this topic!");
                Console.WriteLine();
            }
            Console.WriteLine();
            Console.WriteLine("Which item would you like to buy?");
            Console.WriteLine("Enter 'B' or '0' to go back. Enter 'O' to see your current shopping cart.");
            var  tempInputCollector = new InputCollector();
            bool GoodNumber         = false;
            int  input = 0;

            while (!GoodNumber)
            {
                input = tempInputCollector.GetNumber();
                if (input == 0 || input == 9999)
                {
                    GoodNumber = true;
                }
                if (input > 0 && input <= activeList.Count)
                {
                    GoodNumber = true;
                }
                if (GoodNumber == false)
                {
                    Console.WriteLine("That is not a choice!");
                }
            }
            if (input == 0)
            {
                return(0);
            }
            if (input == 9999)
            {
                int quitint = MyOrderManager.PeekOrder();
                if (quitint == -1)
                {
                    return(-1);
                }
                return(0);
            }
            Save MySaver = new Save();

            MyOrderManager.AddToCurrentOrder(MyStock[MyStoreTopics[x - 1]][input - 1]);
            MySaver.SwapToOrder(activeList[input - 1].GetName());
            Console.WriteLine($"{activeList[input-1].GetName()} has been added to your order. ");
            MyStock[MyStoreTopics[x - 1]].RemoveAt(input - 1);
            Console.WriteLine();
            Console.WriteLine("Press enter to continue.");
            Console.ReadLine();
            return(0);
        }