Created
October 7, 2022 10:57
-
-
Save azeezco/94e92ad555f54562f9d7ee4c1c248ba5 to your computer and use it in GitHub Desktop.
Console bank that does withdrawal and deposit transaction. Can also check balance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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