Skip to content

Instantly share code, notes, and snippets.

@oriohac
Last active October 21, 2022 02:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oriohac/64a748d8aa7565b9a29bb24e148b43a7 to your computer and use it in GitHub Desktop.
Save oriohac/64a748d8aa7565b9a29bb24e148b43a7 to your computer and use it in GitHub Desktop.
Week 4: Imports and Classes

Week 4: Imports and Classes

Created with <3 with dartpad.dev.

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