コード例 #1
0
 private void Bet()
 {
     try
     {
         decimal amount = EnterConsoleValue.GetDecimal("Enter your Amount, please");
         Console.WriteLine("Enter your Currency, please");
         string currency = Console.ReadLine();
         if (currency == "Stop")
         {
             throw new StopException();
         }
         ActivePlayer.Withdraw(amount, currency);
         decimal result = betService.Bet(amount);
         if (result != 0)
         {
             ActivePlayer.Deposit(result, currency);
             Console.WriteLine("You win: {0} {1}", result, currency);
         }
         else
         {
             Console.WriteLine("You lose");
         }
     }
     catch (StopException)
     {
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: trol80lvl2/HW2
        static void Main(string[] args)
        {
            try
            {
                Player player = new Player("Vasya", "Gritsin", "*****@*****.**", "123", "EUR");
                player.Deposit(100, "UAH");
                player.Withdraw(2, "USD");
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("Try again bro");
            }
            catch
            {
                throw;
            }



            Console.ReadLine();
        }