Exemple #1
0
        public static void Main(string[] args)
        {
            //Customer2 cus1 = new Customer2("Tan Ah Kow", "2 Rich Street",
            //                          "P123123", 20);
            //Customer2 cus2 = new Customer2("Kim May Mee", "89 Gold Road",
            //                          "P334412", 60);

            // Redefine depend on reference variables....

            //BankAccount3 a1 = new BankAccount3("S0000223", cus1, 2000);
            //Console.WriteLine(a1.CalculateAnnualInterest());
            //OverDraftAccount a2 = new OverDraftAccount("O1230124", cus1, 2000);
            //Console.WriteLine(a2.CalculateAnnualInterest());
            //CurrentAccount a3 = new CurrentAccount("C1230125", cus2, 2000);
            //Console.WriteLine(a3.CalculateAnnualInterest());

            // Override method
            //BankAccount3 a1 = new BankAccount3("S0000223", cus1, 2000);
            //Console.WriteLine(a1.CalculateAnnualInterest());

            //BankAccount3 a2 = new OverDraftAccount("O1230124", cus1, 2000);
            //Console.WriteLine(a2.CalculateAnnualInterest());

            //BankAccount3 a3 = new CurrentAccount("C1230125", cus2, 2000);
            //Console.WriteLine(a3.CalculateAnnualInterest());

            //... For Workshop 5 ...
            BankBranch branch = new BankBranch("KOKO Bank Branch",
                                               "Tan Mon Nee");
            Customer2 cus1 = new Customer2("Tan Ah Kow", "2 Rich Street",
                                           "P345123", 40);
            Customer2 cus2 = new Customer2("Lee Tee Kim", "88 Fatt Road",
                                           "P678678", 54);
            Customer2 cus3 = new Customer2("Alex Gold", "91 Dream Cove",
                                           "P333221", 34);

            branch.AddAccount(new BankAccount3("S1230123", cus1, 2000));
            branch.AddAccount(new OverDraftAccount("O1230124", cus1, 2000));
            branch.AddAccount(new CurrentAccount("C1230125", cus2, 2000));
            branch.AddAccount(new OverDraftAccount("O1230126", cus3, -2000));
            branch.PrintCustomers();
            branch.PrintAccounts();
            Console.WriteLine(branch.TotalInterestEarned());
            Console.WriteLine(branch.TotalInterestPaid());
            branch.CreditInterest();
            branch.PrintAccounts();
        }
Exemple #2
0
        public void PrintCustomers()
        {
            List <Customer2> customerList = new List <Customer2>();

            for (int i = 0; i < bankAccounts.Count; i++)
            {
                Customer2 customer = bankAccounts[i].AccountHolder;
                if (customerList.IndexOf(customer) < 0)
                {
                    customerList.Add(customer);
                }
            }
            Console.WriteLine("Customer Name\tAddress\t\tPassport\tAge");
            foreach (Customer2 customer in customerList)
            {
                Console.WriteLine(string.Format("{0}\t{1}\t{2}\t\t{3}", customer.Name, customer.Address, customer.PassportNumber, customer.Age));
            }
        }
Exemple #3
0
 public void SetAccountHolder(Customer2 accountHolder)
 {
     this.accountHolder = accountHolder;
 }
Exemple #4
0
 public OverDraftAccount(string accountNumber, Customer2 accountHolder, double balance)
     : base(accountNumber, accountHolder, balance)
 {
 }
Exemple #5
0
 public BankAccount3(string accountNumber, Customer2 accountHolder, double balance)
 {
     this.accountNumber = accountNumber;
     this.accountHolder = accountHolder;
     this.balance       = balance;
 }
Exemple #6
0
 public CurrentAccount(string accountNumber, Customer2 accountHolder, double balance) : base(accountNumber, accountHolder, balance)
 {
 }
Exemple #7
0
        /// <summary>
        /// Main demo
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //Customer1 custA = new Customer1();
            //Customer1 custB = new Customer1();

            //custA.CustomerID = "AAAA";
            //custB.CustomerID = "BBBB";

            //Console.WriteLine("CustA customerid = " + custA.CustomerID);
            //Console.WriteLine("CustB customerid = " + custB.CustomerID);

            //custA.DisplayID();
            //custB.DisplayID();

            //custA.DisplayID("custa");

            //Customer2 custA = new Customer2("AAAA");
            //Customer2 custB = new Customer2("BBBB");

            //custA.CustomerName = "Maria god";
            //custB.CustomerName = "John Doe";

            //custA.UpdateLocation("newyour", "new uork", "10010");

            //custB.UpdateLocaton("toronto", "Ontario", "AX2FD3","CAN");


            //Console.WriteLine(custA.GetLocation());
            //Console.WriteLine(custA.Country);

            //Console.WriteLine(custB.Location);
            //Console.WriteLine(custB.Country);

            //StreamDemo x = new StreamDemo();
            //x = null;

            //GC.Collect();

            //DisposeDemo demo = null;

            //try
            //{
            //    demo = new DisposeDemo();
            //}
            //finally
            //{
            //    if (demo != null)
            //    {
            //        demo.Dispose();

            //    } }

            //using (DisposeDemo demo = new DisposeDemo())
            //{

            //}

            //Customer2 cust = new Customer2("AAAA");
            //cust.CustomerName = "John Doe";
            //Console.WriteLine(cust.ToString());


            //int intA = 10;
            //int intB = 0;

            //Console.WriteLine("before  A={0}, B={1}", intA, intB);

            //intB = intA;

            //intB = 15;

            //Console.WriteLine("after  A={0}, B={1}", intA, intB);


            //Customer2 custA = new Customer2("AAAA");
            //Customer2 custB = null;

            //custA.CustomerName = "John Doe";
            //Console.WriteLine("Before {0}", custA.ToString());

            //custB = custA;

            //custB.CustomerName = "Mary Jane";

            //Console.WriteLine("After {0}", custA.ToString());

            //string value = "ABCDE";

            //int pos = value.IndexOf("B");
            //Console.WriteLine("pos = {0}", pos);

            //Console.WriteLine(
            //    String.Concat("Concatenate ", "these ", "Together"));



            //Customer2 custA = new Customer2("AAAA");
            //Console.WriteLine("custA.Country = " + custA.Country);

            //Customer2.DefaultCountry = "UK";
            //Customer2 custB = new Customer2("BBBB");
            //Console.WriteLine("custA.Country = " + custA.Country);
            //Console.WriteLine("custB.Country = " + custB.Country);

            Customer2 someCustomer = new Customer2("AAA");

            someCustomer.CustomerName = "Application Developer Training Company";
            someCustomer.City         = "Eden Prairie";
            someCustomer.Region       = "MN";
            someCustomer.PostalCode   = "55344";

            Console.WriteLine("Customer info");
            Console.WriteLine(someCustomer.CustomerName);
            Console.WriteLine(someCustomer.Location);
            Console.WriteLine(someCustomer.Country);

            Console.WriteLine();

            someCustomer.UpdateLocation("encino", "Cal", "91436");

            Console.WriteLine("Customer info");
            Console.WriteLine(someCustomer.CustomerName);
            Console.WriteLine(someCustomer.Location);
            Console.WriteLine(someCustomer.Country);
        }