Exemplo n.º 1
0
        // distinct selling for outer economies
        private void OpSellMenu()
        {
            Console.WriteLine();
            Console.WriteLine("What would you like to sell?");

            int optionIndex = 1;

            int optionCase1 = 0;
            int optionCase2 = 0;
            int optionCase3 = 0;
            int optionCase4 = 0;
            int optionCase5 = 0;

            if (MyShip.GetItemQuant(3) > 0)
            {
                Console.WriteLine($"{optionIndex} = Pizza for {MyShip.GetPrice(0)} credits / each");
                optionCase1 = optionIndex++;
            }
            if (MyShip.GetItemQuant(4) > 0)
            {
                Console.WriteLine($"{optionIndex} = Op1Item for {MyShip.GetPrice(-1)} credits / each");
                optionCase2 = optionIndex++;
            }
            if (MyShip.GetItemQuant(5) > 0)
            {
                Console.WriteLine($"{optionIndex} = Op2Item for {MyShip.GetPrice(1)} credits / each");
                optionCase3 = optionIndex++;
            }
            if (MyShip.GetItemQuant(6) > 0)
            {
                Console.WriteLine($"{optionIndex} = Op3Item for {MyShip.GetPrice(0)} credits / each");
                optionCase4 = optionIndex++;
            }
            if (MyShip.GetItemQuant(7) > 0)
            {
                Console.WriteLine($"{optionIndex} = Op4Item for {MyShip.GetPrice(-1)} credits / each");
                optionCase5 = optionIndex++;
            }

            try
            {
                int option = int.Parse(Console.ReadLine());

                // if input matches the corresponding optionCase, statement is executed.
                if (option == optionCase1 && option != 0)
                {
                    OpSellItem(3);
                }
                else if (option == optionCase2 && option != 0)
                {
                    OpSellItem(4);
                }
                else if (option == optionCase3 && option != 0)
                {
                    OpSellItem(5);
                }
                else if (option == optionCase4 && option != 0)
                {
                    OpSellItem(6);
                }
                else if (option == optionCase5 && option != 0)
                {
                    OpSellItem(7);
                }
                else
                {
                    Console.WriteLine("You did not pick a valid option.");
                }
            }
            catch (Exception)
            {
                MainError();
            }
        }