コード例 #1
0
        /*
         * This method determines what kind of temperature conversion is to be done.
         * It asks for the user's choice at least once (hence the do-while loop) and
         * continues asking until the user has provided a correct answer (1 or 2).
         */
        private void ReadTypeOfConversion()
        {
            DisplayConversionChoices();
            do
            {
                wrongInput = false;

                int choice = ConsoleInput.ReadInt();
                if (choice == 1)
                {
                    convertToCelsius = false;
                }
                else if (choice == 2)
                {
                    convertToCelsius = true;
                }
                else
                {
                    DisplayWrongInputMessage();
                }
            }while (wrongInput);
        }
コード例 #2
0
ファイル: Menu.cs プロジェクト: jonazeiselt/da204b
 /* Asks user for menu choice until a valid one has been entered. */
 private void ReadMenuInput()
 {
     Console.Write("Your choice: ");
     menuChoice = ConsoleInput.ReadInt();
 }
コード例 #3
0
 /* Reads the foreign currency exhange rate in proportion to SEK currency. */
 private void ReadForeignCurrencyExchangeRate()
 {
     Console.Write("Enter the foreign currency exchange rate, meaning how many " +
                   "SEK are equal to 1 " + foreignCurrency + ": ");
     foreignCurrencyExchangeRate = (decimal)ConsoleInput.ReadDouble();
 }