Exemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Enter account data");
                Console.Write("Number: ");
                int number = int.Parse(Console.ReadLine());
                Console.Write("Holder: ");
                string holder = Console.ReadLine();
                Console.Write("Initial balance: ");
                double initial = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                Console.Write("Withdraw limit: ");
                double limit = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);

                Account account = new Account(number, holder, initial, limit);

                Console.WriteLine();
                Console.Write("Enter amount for withdraw: ");
                double amount = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
                account.WithDraw(amount);
                Console.Write("New balance: " + account.Balance.ToString("F2", CultureInfo.InvariantCulture));
            }
            catch (WithDrawException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            CultureInfo CI = CultureInfo.InvariantCulture;

            Console.WriteLine("Enter Account Data");
            Console.WriteLine();

            Console.Write("Number: ");
            int number = int.Parse(Console.ReadLine());

            Console.Write("Holder: ");
            string name = Console.ReadLine();

            Console.Write("Balance: ");
            double balance = double.Parse(Console.ReadLine(), CI);

            Console.Write("WithDraw Limit: ");
            double withDrawLimit = double.Parse(Console.ReadLine(), CI);

            Account account = new Account(number, name, balance, withDrawLimit);

            Console.WriteLine();

            Console.Write("Enter the Withdraw amount: ");
            double amount = double.Parse(Console.ReadLine(), CI);

            Console.WriteLine();

            try
            {
                account.WithDraw(amount);
                Console.WriteLine("Trasaction sucessful! \n" + "New Balance: $" + account.Balance.ToString("F2", CI));
            }
            catch (DomainException e)
            {
                Console.WriteLine("Withdraw error: " + e.Message);
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Account a1 = new Account(1000.0);

            try
            {
                Console.WriteLine(a1.Balance);
                a1.WithDraw(1100);
            }
            catch (InvalidAmountException e)
            {
                Console.WriteLine($"{e.Message}, invalid value: {e.Amount}");
            }
            try
            {
                Account.SetInterestRate(22.7);
            }
            catch (InvalidInterestRateException e)
            {
                Console.WriteLine($"{e.Message}, invalid value: {e.InterestRate}");
            }
            Console.ReadKey();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Enter account data");
                Console.Write("Number: ");
                int number = Convert.ToInt32(Console.ReadLine());
                Console.Write("Holder: ");
                string holder = Console.ReadLine();
                Console.Write("Initial balance: ");
                double iBalance = Convert.ToDouble(Console.ReadLine());
                Console.Write("Withdraw limit: ");
                double  withDrawLimit = Convert.ToDouble(Console.ReadLine());
                Account account       = new Account(number, holder, iBalance, withDrawLimit);

                Console.Write("\nEnter amount for withdraw: ");
                double amount = Convert.ToDouble(Console.ReadLine());
                account.WithDraw(amount);
                Console.WriteLine("New balance: " + account.Balance.ToString("F2"));
            }
            catch (DomainException e) {
                Console.WriteLine("Withdraw error: " + e.Message);
            }
        }
        public void WithDraw()
        {
            Account sender = new Account();

            sender.WithDraw(1000);
        }