Exemple #1
0
        static void Main(string[] args)
        {
            /*
             * try
             * {
             *  Triangle r = new Triangle(3, 4, 8);
             *  Console.WriteLine(r.GetParameter());
             *  Console.WriteLine(r.GetArea());
             * }
             * catch (Exception e)
             * {
             *  Console.WriteLine(e.Message);
             * }
             * finally
             * {
             *  Console.WriteLine("End");
             * }
             */
            Customer cus1 = new Customer("Tan Ah Kow", "2 Rich Street",
                                         "P345123", new DateTime(1990, 01, 01));
            Customer cus2 = new Customer("Lee Tee Kim", "88 Fatt Road",
                                         "P678678", new DateTime(1975, 03, 07));
            Customer cus3 = new Customer("Alex Gold", "91 Dream Cove",
                                         "P333221", new DateTime(1983, 07, 07));
            BankAccount3 b1 = new SavingsAccount("S1230123", cus1);
            BankAccount3 b2 = new OverDraftAccount("O1230124", cus1);
            BankAccount3 b3 = new CurrentAccount("C1230125", cus2);
            BankAccount3 b4 = new OverDraftAccount("O1230126", cus3);

            try
            {
                b1.Deposit(3000);
                b1.TransferTo(4000, b1);
                Console.WriteLine(b1.Balance);
            }catch (BalanceException e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                Console.WriteLine("End");
            }
        }
Exemple #2
0
        public static void Main()
        {
            Customer cus1 = new Customer("Tan Ah Kow", "2 Rich Street",
                                         "P123123", 20);
            SavingsAccount a1 = new SavingsAccount("S0000223", cus1, 2000);

            Customer cus2 = new Customer("Kim May Mee", "89 Gold Road",
                                         "P334412", 60);
            CurrentAccount a2 = new CurrentAccount("O1230124", cus2, 2000);

            Customer cus3 = new Customer("Jeremy Tan", "89 Tanjong Pagar",
                                         "P126838", 30);
            OverdraftAccount a3 = new OverdraftAccount("C1230125", cus3, 1000);

            try
            {
                a1.Withdraw(3000);
            } catch (NegativeBalanceException e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                a2.Withdraw(3000);
            }
            catch (NegativeBalanceException e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                a3.Withdraw(2000);
            }
            catch (NegativeBalanceException e)
            {
                Console.WriteLine(e);
            }
        }