Skip to content

Instantly share code, notes, and snippets.

@azeezco
Created October 7, 2022 10:57
Show Gist options
  • Save azeezco/94e92ad555f54562f9d7ee4c1c248ba5 to your computer and use it in GitHub Desktop.
Save azeezco/94e92ad555f54562f9d7ee4c1c248ba5 to your computer and use it in GitHub Desktop.
Console bank that does withdrawal and deposit transaction. Can also check balance.
class Account {
Account(this.accountNumber, this.accountBalance, this.accountName);
final String accountName;
final int accountNumber;
int accountBalance;
checkBalance() => print("Your account balance is $accountBalance");
makeDeposit(int depositAmount) {
accountBalance = accountBalance + depositAmount;
print("Money deposited successfully");
}
makeWithdrawal(int withdrawAmount) {
if (withdrawAmount <= accountBalance) {
accountBalance = accountBalance - withdrawAmount;
} else {
print("Insufficient funds");
}
}
}
void main() {
final String myAccountName = "Lawal Azeez Ayotunde";
final int myAccountNumber = 0137823780;
int myAccountBalance = 1000;
int withdrawAmount = 100;
int depositAmount = 100;
Account myAccount =
new Account(myAccountNumber, myAccountBalance, myAccountName);
myAccount.checkBalance();
myAccount.makeWithdrawal(withdrawAmount);
myAccount.makeDeposit(depositAmount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment