public BankAccount(double accountBalance)
AccountBalance = accountBalance;
public void TransferIn(double amount, BankAccount otherAccount)
throw new Exception("Insufficient funds");
if (otherAccount.AccountBalance < amount)
throw new Exception("Insufficient funds");
AccountBalance += amount;
otherAccount.AccountBalance -= amount;
public void TransferOut(double amount, BankAccount otherAccount)
throw new Exception("Insufficient funds");
if (AccountBalance < amount)
throw new Exception("Insufficient funds");
AccountBalance -= amount;
otherAccount.AccountBalance += amount;
public double AccountBalance { get; private set; }
public static void Main(string[] args)
var bankAccount1 = new BankAccount(250000);
var bankAccount2 = new BankAccount(1000000);
bankAccount1.TransferIn(20000, bankAccount2);
Console.WriteLine($"Account 1 Balance: { bankAccount1.AccountBalance }");
Console.WriteLine($"Account 2 Balance: {bankAccount2.AccountBalance}");