Elite 102 - Starter Repo Setup Guide
This guide will help students clone and run a starter banking app project with a BankAccount class. The project uses SQLite for data persistence and is designed to be run in the command line using Python.
banking-app/
├── main.py
├── bank_account.py
└── bank.db (generated after running)
- Log in to your GitHub account.
- Create a new public repository (you can name it
banking-appor something similar). - Open your terminal or command prompt.
- Navigate to the folder where you want to store your project:
cd path/to/your/folder - Clone the repo:
git clone https://github.com/ju-dominguez/elite_102_project.git
- Open the folder in VS Code:
File > Open Folder > Select your cloned folder
- In VS Code, go to the Extensions tab (left sidebar or press
Ctrl+Shift+X) - Search for
SQLite Viewer - Click "Install"
- This will let you visually inspect your
bank.dbfile and browse data easily
Create a file called bank_account.py with the following content:
import sqlite3
class BankAccount:
def __init__(self, user_id):
self.user_id = user_id
self.conn = sqlite3.connect('bank.db')
self.cursor = self.conn.cursor()
self.create_table()
def create_table(self):
self.cursor.execute('''
CREATE TABLE IF NOT EXISTS accounts (
user_id TEXT PRIMARY KEY,
balance REAL DEFAULT 0.0
)
''')
self.conn.commit()
def create_account(self):
self.cursor.execute('INSERT OR IGNORE INTO accounts (user_id, balance) VALUES (?, ?)', (self.user_id, 0.0))
self.conn.commit()
# TODO: Add the following functions:
# def deposit(self, amount):
# def withdraw(self, amount):
# def get_balance(self):Create a file called main.py with this test interface:
from bank_account import BankAccount
user_id = input("Enter your user ID: ")
account = BankAccount(user_id)
account.create_account()
while True:
print("\nChoose an option:")
print("1. Check Balance")
print("2. Deposit")
print("3. Withdraw")
print("4. Exit")
choice = input("Enter your choice (1–4): ")
if choice == '1':
# Call get_balance() once you've implemented it
pass
elif choice == '2':
# Prompt for amount and call deposit()
pass
elif choice == '3':
# Prompt for amount and call withdraw()
pass
elif choice == '4':
print("Goodbye!")
break
else:
print("Invalid choice. Try again.")✅ Your Task
Implement the following methods in your BankAccount class:
deposit(self, amount)
- Increases the user’s balance by the specified amount
withdraw(self, amount)
- Decreases the user’s balance by the specified amount if there are enough funds
get_balance(self)
- Retrieves and returns the user’s current balance
You can reference the structure of create_account() to see how database queries are written.
In your terminal, navigate to the folder that contains main.py and run:
python main.pyYou’ll be prompted to enter your user ID and then interact with your account via CLI.
After implementing each method:
- Add a
print()statement to confirm the correct value was returned - Try depositing or withdrawing values and checking the balance afterward
- Make sure your logic for insufficient funds works in
withdraw()
Install the SQLite Viewer extension in VS Code so you can view your bank.db database file visually and verify that your data is being saved correctly.
You’re now set up to start building and customizing your own banking app! 🎉