示例#1
0
        public static void Main()
        {
            Console.WriteLine("Enter account data");

            try
            {
                Console.Write("Number: ");
                Console.ForegroundColor = ConsoleColor.Red;
                int number = int.Parse(Console.ReadLine());
                Console.ResetColor();

                Console.Write("Holder: ");
                Console.ForegroundColor = ConsoleColor.Red;
                string holder = Console.ReadLine();
                Console.ResetColor();

                Console.Write("Initial balance: ");
                Console.ForegroundColor = ConsoleColor.Red;
                double initialBalance = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.ResetColor();

                Console.Write("Withdraw limit: ");
                Console.ForegroundColor = ConsoleColor.Red;
                double withdrawLimit = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.ResetColor();

                Entities.Account account = new Entities.Account(number, holder, initialBalance, withdrawLimit);

                Console.WriteLine();
                Console.Write("Enter amount for withdraw: ");
                Console.ForegroundColor = ConsoleColor.Red;
                double withdraw = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.ResetColor();
                account.withdraw(withdraw);
                Console.WriteLine("New balance: " + account.Balance.ToString("F2", CultureInfo.InvariantCulture));
            }
            catch (Exception e)
            {
                Console.ResetColor();
                Console.WriteLine(e.Message);
            }
            finally
            {
                Console.ReadLine();
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Account number: ");
                int number = int.Parse(Console.ReadLine());

                Console.WriteLine("Holder: ");
                string holder = Console.ReadLine();

                Console.WriteLine("Limit: ");
                double limit = double.Parse(Console.ReadLine());

                Entities.Account account = new Entities.Account(number, holder, 0.0, limit);

                Console.WriteLine("Deposit value: ");
                double deposit = double.Parse(Console.ReadLine());

                account.Deposit(deposit);

                Console.WriteLine("Withdraw value: ");
                double withdraw = double.Parse(Console.ReadLine());

                account.Withdraw(withdraw);
            } catch (DominioException m)
            {
                Console.WriteLine(m);
            } catch (StackOverflowException stack)
            {
                Console.WriteLine(stack.HelpLink);
                Console.WriteLine();
                Console.WriteLine(stack.Message);
                Console.WriteLine();
                Console.WriteLine(stack.Source);
            }

            Console.WriteLine("Encerrado!");
            Console.ReadKey();
        }