Exemplo n.º 1
0
        /// <summary>
        /// Gets a transaction amount for the given company.
        /// </summary>
        /// <param name="company">
        /// The company to buy or sell.
        /// </param>
        /// <returns>
        /// The number of shares to buy or sell.
        /// </returns>
        public static int GetTransactionAmount(Company company)
        {
            while (true)
            {
                View.PromptBuySellCompany(company);

                var input = Console.ReadLine();
                if (input is null)
                {
                    Environment.Exit(0);
                }
                else
                if (!Int32.TryParse(input, out var amount))
                {
                    View.PromptValidInteger();
                }
                else
                {
                    return(amount);
                }
            }
        }