Created with <3 with dartpad.dev.
Last active
October 21, 2022 02:13
-
-
Save oriohac/64a748d8aa7565b9a29bb24e148b43a7 to your computer and use it in GitHub Desktop.
Week 4: Imports and Classes
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
void main() { | |
Bank money = Bank(); | |
money.availableBalance(); | |
money.deposit(23999); | |
money.withdrawal(160000); | |
} | |
class Bank { | |
static const accountName = "Chike"; | |
static const accountNumber = 2086057301; | |
double accountBalance = 150000.20; | |
void availableBalance() { | |
print("Dear $accountName with account number $accountNumber your account balance is: $accountBalance"); | |
} | |
void deposit(double amount){ | |
accountBalance = amount + accountBalance; | |
if(amount > 0){ | |
print("Money deposited successfully!" "\t" "Your Balance is: $accountBalance"); | |
}else{ | |
print("Amount too small for deposit"); | |
} | |
} | |
void withdrawal(double amount){ | |
accountBalance = accountBalance - amount; | |
if (amount > accountBalance){ | |
print("Insufficient funds!"); | |
}else{ | |
print("You have withdrawn: $amount and your balance is: $accountBalance"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment