















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
















accountNumber accountHolder balance deposit() withdraw()
accountNumber accountHolder balance deposit() withdraw()
12345 John Smith 1000 deposit() withdraw()
accountNumber accountHolder balance deposit() withdraw()
public class CurrentAccount : BankAccount { private int overdraftFacility; public CurrentAccount(n, name, b) {…} public override void withdraw(int amount) { if (balance - amount > - overdraftFacility) balance - = amount; } } public class BankAccount { //…… public virtual void withdraw(int amount) { if (balance - amount > - overdraftFacility) balance - = amount; } }
public class BankAccountTest { static void Main(string[] args) { BankAccount acc1 = new CurrentAccount(12345, "John Smith“,1000, 500); acc1.withdraw(250); // Calls the CurrentAccount withdraw() method } }
public class BankAccountTest { static void Main(string[] args) { BankAccount acc1 = new CurrentAccount(12345, "John Smith“,1000, 500); acc1.withdraw(250); // Calls the CurrentAccount withdraw() method BankAccount acc2 = new DepositAccount(54321, “Bill Jones“,2000, 5.0); acc2.withdraw(100); // Calls the BankAccount withdraw() method } }
public class BankAccount { private int accountNumber; private string accountHolder; private int balance; public BankAccount(int n,string name ,int b) {
balance = b; } public int AccountNumber { // accountNumber property} public string AccountHolder { // accounHolder property} public int Balance { // balance property} public void withdraw(int amount) { if (balance>amount) balance-=amount; } public void deposit(int amount) { balance+=amount;} public override bool Equals(object obj) { BankAccount b = (BankAccount) obj; return (accountNumber==b.accountNumber); } }