This repository contains a simple Dart script designed to simulate basic bank account operations, making it ideal for simple expense tracking and financial management. It allows you to deposit, withdraw, and check the balance of a virtual bank account.
Ensure you have Dart installed on your system. If not, you can download and install it from the Dart SDK.
- Download the
myBankAcc.dartscript from this repository. - Save the file in the same directory as your working file.
To use the BankAccount class in your Dart application, follow these steps:
import 'myBankAcc.dart';
void main() {
var bankAccount = BankAccount();
}To deposit money into your account, use the .deposit method:
bankAccount.deposit(amount); // Deposit $3000To check your current balance, use the .myBalance method:
bankAccount.myBalance(); // Displays the current balanceTo withdraw money from your account, use the .withdraw method:
bankAccount.withdraw(amount); // Withdraw $1400
Again, you can check your balance using .myBalance:
bankAccount.myBalance(); // Displays the updated balanceSuppose you want to track how you've spent a total of $3500. Here's an example of how you can do that:
import 'myBankAcc.dart';
void main() {
var bankAccount = BankAccount();
bankAccount.deposit(3500); // Deposit initial amount
bankAccount.withdraw(1500); // Withdraw an expense
bankAccount.withdraw(750); // Withdraw another expense
bankAccount.deposit(700); // Deposit additional funds
bankAccount.deposit(825); // Another deposit
bankAccount.withdraw(625); // Final withdrawal
bankAccount.myBalance(); // Check final balance
}
// Expected Output: Your balance is $2150In this example, various transactions are performed, and the final balance is displayed, providing a clear picture of your expenses and remaining funds.