コード例 #1
0
 static void Main(string[] args)
 {
     /*
      * Customer2 c = new Customer2("Tan Ah Kow", "4 Short Street");
      * int n = 65;
      * Console.WriteLine(n);
      * Console.WriteLine(c);
      * Console.WriteLine(n.ToString());
      * Console.WriteLine(c.ToString());
      *
      * Rational a = new Rational(0, 2);
      * Rational b = new Rational(4, 5);
      * Rational c = a + b;    // c=operator+(a,b);
      * Console.WriteLine(c);
      * c = b - a;
      * Console.WriteLine(c);
      *
      * BankBranch branch = new BankBranch("KOKO Bank Branch","Tan Mon Nee");
      * 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(1987,03,07));
      * Customer cus3 = new Customer("Alex Gold", "91 Dream Cove", "P333221",new DateTime(2000,09,06));
      * branch.AddAccount(new SavingsAccount("S1230123", cus1));
      * branch.AddAccount(new OverDraftAccount("O1230124", cus1));
      * branch.AddAccount(new CurrentAccount("C1230125", cus2));
      * branch.AddAccount(new OverDraftAccount("O1230126", cus3));
      * branch.PrintCustomers();
      * branch.PrintAccounts();
      * Console.WriteLine(branch.TotalInterestEarned());
      * Console.WriteLine(branch.TotalInterestPaid());
      */
     Customer     y = new Customer("Tan Ah Kow", "20, Seaside Road", "XXX20", new DateTime(1989, 10, 11));
     Customer     z = new Customer("Kim Lee Keng", "2, Rich View", "XXX9F", new DateTime(1993, 4, 25));
     BankAccount3 a = new BankAccount3("001-001-001", y);
     BankAccount3 b = new BankAccount3("001-001-002", z);
 }
コード例 #2
0
 public void TransferTo(double amount, BankAccount3 another)
 {
     if (amount > balance)
     {
         Console.WriteLine("Cannot transfer the amount greater than balance");
     }
     else
     {
         balance = balance - amount;
         another.Deposit(amount);
         Console.WriteLine("Transfer ${0} dollars to {1}'account:{2}", amount, another.AccountHolderName, another.AccountNumber);
     }
 }
コード例 #3
0
        public double TotalInterestEarned()
        {
            double total = 0;

            for (int i = 0; i < BankAccounts.Count; i++)
            {
                BankAccount3 a    = (BankAccount3)BankAccounts[i];
                double       intr = a.CalculateInterest();
                if (intr < 0)
                {
                    total += (-intr);
                }
            }
            return(total);
        }
コード例 #4
0
        public double TotalDeposits()
        {
            double total = 0;

            for (int i = 0; i < BankAccounts.Count; i++)
            {
                BankAccount3 a   = (BankAccount3)BankAccounts[i];
                double       bal = a.Balance;
                if (bal > 0)
                {
                    total += bal;
                }
            }
            return(total);
        }
コード例 #5
0
        public void PrintCustomers()
        {
            List <Customer> customerList = new List <Customer>();

            for (int i = 0; i < BankAccounts.Count; i++)
            {
                BankAccount3 a = BankAccounts[i];
                Customer     c = a.AccountHolderName;
                //int c = cust.IndexOf(t);
                //if (c < 0)
                customerList.Add(c);
            }
            foreach (Customer c in customerList)
            {
                Console.WriteLine(c);
            }
        }
コード例 #6
0
 public void AddAccount(BankAccount3 b)
 {
     BankAccounts.Add(b);
 }
コード例 #7
0
 public new void TransferTo(double amount, BankAccount3 another)
 {
     balance = balance - amount;
     another.Deposit(amount);
     Console.WriteLine("Transfer ${0} dollars to {1}'account:{2}", amount, another.AccountHolderName, another.AccountNumber);
 }
コード例 #8
0
 public void AddAccount(BankAccount3 a)
 {
     accounts.Add(a);
     numberOfAccounts++;
 }