Пример #1
0
        public void MyCode()
        {
            // The FIRST line of code should be BELOW this line

            // Create a new BankAccount object
            BankAccount acc = new BankAccount("Anna");

            // What is the initial balance (should be 0)?
            Console.WriteLine("{0}'s account has a balance of {1}", acc.GetName(), acc.GetBalance());

            acc.Deposit(1000.0);
            acc.Deposit(1300.0);

            // What is the balance after some deposits (should be 2300)?
            Console.WriteLine("{0}'s account has a balance of {1}", acc.GetName(), acc.GetBalance());

            acc.Withdraw(2000.0);
            acc.Withdraw(800.0);

            // What is the balance after some withdrawals (should be -500)?
            Console.WriteLine("{0}'s account has a balance of {1}", acc.GetName(), acc.GetBalance());

            acc.Deposit(1000.0);
            acc.Deposit(2800.0);

            // What is the balance after some deposits (should be 3300)?
            Console.WriteLine("{0}'s account has a balance of {1}", acc.GetName(), acc.GetBalance());

            acc.AssignInterest(6.0);

            // What is the balance after assigning interest (should be 3498)?
            Console.WriteLine("{0}'s account has a balance of {1}", acc.GetName(), acc.GetBalance());

            // The LAST line of code should be ABOVE this line
        }
Пример #2
0
        public void MyCode()
        {
            // The FIRST line of code should be BELOW this line

            BankAccount myAccount = new BankAccount();

            // Test the BankAccount - make some deposits and withdrawals,
            // and check that the balance behaves as expected
            myAccount.GetBalance();
            Console.WriteLine("Balance is now : {0}", myAccount.GetBalance());


            // The LAST line of code should be ABOVE this line
        }
        public void MyCode()
        {
            // The FIRST line of code should be BELOW this line

            BankAccount myAccount = new BankAccount();

            myAccount.Deposit(-100);
            myAccount.Withdraw(-100);
            myAccount.Deposit(100);
            myAccount.Withdraw(150);
            myAccount.GetBalance();
            Console.WriteLine("Balance is now : {0}", myAccount.GetBalance());

            // The LAST line of code should be ABOVE this line
        }
        public void MyCode()
        {
            // The FIRST line of code should be BELOW this line

            // Create a new bank account with 25 % interest rate
            // (is that legal...?)
            BankAccount theAccount = new BankAccount(25.0);

            theAccount.Deposit(2000);


            // Should this be legal...?
            theAccount.Deposit(-1000);

            // Try to withdraw...
            try
            {
                theAccount.Withdraw(3000);
            }
            catch (WithdrawAmountTooLargeException)
            {
                Console.WriteLine("You tried to withdraw too much money!");
            }


            Console.WriteLine("Balance is now : " + theAccount.GetBalance());

            // The LAST line of code should be ABOVE this line
        }
Пример #5
0
        public void MyCode()
        {
            // The FIRST line of code should be BELOW this line

            BankAccount BankAccount1 = new BankAccount();



            Console.WriteLine($"Account holders name is: {BankAccount1.Getname()}. The balance on the account is: {BankAccount1.GetBalance()} kr");

            BankAccount1.AddDeposit(25);

            Console.WriteLine($"Account holder name is: {BankAccount1.Getname()}. The balance on the account is: {BankAccount1.GetBalance()} kr");

            BankAccount1.AddWithdrawel(200);

            Console.WriteLine($"Account holder name is: {BankAccount1.Getname()}. The balance on the account is: {BankAccount1.GetBalance()} kr");
            // The LAST line of code should be ABOVE this line
        }