示例#1
0
        public static void Main()
        {
            CustomerAccount RobsAccount = new CustomerAccount("Rob Miles", 100);
                Account.InterestRateCharged = 10;
                if (RobsAccount.WithdrawFunds(5))
                {
                    Console.WriteLine("Cash Withdrawn");
                }
                else
                {
                    Console.WriteLine("Insufficient Funds");
                }

                CustomerAccount test = new CustomerAccount("Rob Miles", 100);
                test.PayInFunds(50);
                if (test.GetBalance() != 50)
                {
                    Console.WriteLine("Pay In test failed");
                }

                /*
                IAccount friendlyBank = new ArrayBank(50);
                IAccount account = new CustomerAccount("Rob", 0);
                if (friendlyBank.Save(account))
                {
                    Console.WriteLine( "Account stored OK");
                }*/

                CustomerAccount a = new CustomerAccount("Rob", 50);
                AccountEditTextUI edit = new AccountEditTextUI(a);
                edit.EditName();
        }
示例#2
0
        static void Main(string[] args)
        {
            IAccount  [] accounts = new IAccount[MAX_CUST];
            accounts[0] = new CustomerAccount("Phuong");
            accounts[0].payInFunds(100);
            Console.WriteLine("Balance "+ accounts[0].Balance);

            accounts[1] = new BabyAccount("KKY","Nanterre");
            accounts[1].payInFunds(20);
            accounts[1].withdrawFunds(9);
            accounts[1].Name = "KKYPhuong";
            Console.WriteLine(accounts[0].printWarning());
            Console.WriteLine(accounts[0].ToString());
            Console.WriteLine(accounts[1].ToString());
            Console.WriteLine(accounts[0].Equals(accounts[1]));
            Console.WriteLine(accounts[1].Equals(accounts[0]));

            //Delegate
            CalculateFee calc; //declare an instance of delegate
            calc = new CalculateFee(RipOffFee); // map/call the ripofffee method
            calc(-1);     //execute the method

            calc = new CalculateFee(FriendlyFee);
            calc(-1);

            //Bank

            SGBank myBank = new SGBank();
            myBank.storeAccount(accounts[0]);
            myBank.storeAccount(accounts[1]);
            IAccount found = myBank.findAccount("Phuong");
            Console.WriteLine(found.ToString());
            string d = Console.ReadLine();
        }
示例#3
0
        static void Main(string[] args)
        {
            CustomerAccount test = new CustomerAccount();
            test.PayInFunds(50);
            Console.WriteLine("Balance:" + test.GetBalance());

            int errorCount = 0;

            if (test.GetBalance() != 50)
            {
                Console.WriteLine("Pay In test failed");
            }

            string reply;
            reply = CustomerAccount.ValidateName(null);
            if (reply != "Name parameter null")
            {
                Console.WriteLine("Null name test failed");
                errorCount++;
            }
            reply = CustomerAccount.ValidateName("");
            if (reply != "No text in the name")
            {
                Console.WriteLine("Empty name test failed");
                errorCount++;
            }
            reply = CustomerAccount.ValidateName(" ");
            if (reply != "No text in the name")
            {
                Console.WriteLine("Blank string name test failed");
                errorCount++;
            }
            CustomerAccount a = new CustomerAccount("Rob", 50);
            if (!a.SetName("Jim"))
            {
                Console.WriteLine("Jim SetName failed");
                errorCount++;
            }
            if (a.GetName() != "Jim")
            {
                Console.WriteLine("Jim GetName failed");
                errorCount++;
            }
            if (!a.SetName(" Pete "))
            {
                Console.WriteLine("Pete trim SetName failed");
                errorCount++;
            }
            if (a.GetName() != "Pete")
            {
                Console.WriteLine("Pete GetName failed");
                errorCount++;
            }
            if (errorCount > 0)
            {
                SoundSiren(errorCount);
            }
        }
示例#4
0
        /*This method is supplied with a text stream. It reads the name and the balance from
        this stream and creates a new CustomerAccount based on this data.*/
        public static CustomerAccount Load(System.IO.TextReader textIn)
        {
            CustomerAccount result = null;

            try
            {
                string name = textIn.ReadLine();
                string balanceText = textIn.ReadLine();
                decimal balance = decimal.Parse(balanceText);
                result = new CustomerAccount(name, balance);
            }
            catch
            {
                return null;
            }
            return result;
        }