Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions BankingSystem/pythonProject/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions BankingSystem/pythonProject/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions BankingSystem/pythonProject/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions BankingSystem/pythonProject/.idea/pythonProject.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions BankingSystem/pythonProject/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions BankingSystem/pythonProject/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from models.Bank import Bank
from models.User import User


def load_initial_user():
user: User = User(username="cval0", password="tryHackMe")
return user


def main():
bank: Bank = Bank()
bank.register_user(load_initial_user())
loop: bool = True
active_user = None
while loop:
option = bank.menu()
if option == 1:
username = input("Define username: ")
password = input("Password: ")
bank.register_user(User(username, password))
elif option == 2:
active_user = bank.login()
elif option == 3:
if active_user is not None:
amount = float(input("Withdraw amount: "))
active_user.withdraw(amount)
else:
print("Not logged in yet")
elif option == 4:
if active_user is not None:
amount = float(input("Deposit amount: "))
active_user.deposit(amount)
else:
print("Not logged in yet")
elif option == 5:
if active_user is not None:
destiny_user = input("Destiny user: ")
amount = float(input("Transfer amount: "))
bank.transfer(origin_account=active_user, destination_account=destiny_user, amount=amount)
else:
print("Not logged in yet")
elif option == 6:
if active_user is not None:
active_user.view()
else:
print("Not logged in yet")
else:
loop = False


if __name__ == "__main__":
main()
71 changes: 71 additions & 0 deletions BankingSystem/pythonProject/models/Bank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from models.User import User


class Bank(object):
users: dict[str, User]

def __init__(self, users=None):
if users is None:
users = {}
self.users = users

def menu(self):
print("BANKING SYSTEM")
print("1. Register new account")
print("2. Login")
print("3. Withdraw")
print("4. Deposit")
print("5. Transfer")
print("6. View")
option = int(input(">> "))
return option

def login(self) -> User:

attempts: int = 3
while attempts != 0:
username = input("Username: ")
password = input("Password: ")

if username not in self.users:
print("User not registered")
continue

user = self.users.get(username)

if user.username == username and user.password == password:
print("Successfully logged in")
return user
else:
print("Incorrect credentials")
attempts -= 1
if attempts == 0:
user.is_blocked = True
print("Your account will be blocked for security reasons")

return None

def register_user(self, user: User):
if user.username not in self.users.keys():
self.users.update({user.username: user})
else:
print("User already registered")

def transfer(self, origin_account: User, destination_account: str, amount: float) -> bool:

if origin_account.username not in list(self.users.keys()) or destination_account not in list(self.users.keys()):
print("Account not registered")
return False

if origin_account.balance < amount:
print("Not enough funds to perform transfer")
return False

if origin_account.is_blocked or self.users.get(destination_account).is_blocked:
print("Account blocked, transform cannot be performed")
return False

origin_account.withdraw(amount)
self.users.get(destination_account).deposit(amount)

return True
28 changes: 28 additions & 0 deletions BankingSystem/pythonProject/models/User.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class User(object):
username: str
password: str
is_blocked: bool
balance: float = 2000

def __init__(self, username: str, password: str, is_blocked=False, balance=2000):
self.username = username
self.password = password
self.balance = balance
self.is_blocked = is_blocked

def deposit(self, amount: float) -> bool:
self.balance += amount
return True

def withdraw(self, amount: float) -> bool:
if self.balance - amount < 0:
print("Not enough available funds")
return False
else:
self.balance -= amount
return True

def view(self) -> None:
print(f"Your balance is {self.balance}")


Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions FinanceManagement/.idea/FinanceManagement.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions FinanceManagement/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions FinanceManagement/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions FinanceManagement/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions FinanceManagement/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions FinanceManagement/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
def main():
categories = [
"Medical expenses",
"Household expenses",
"Leisure",
"Education",
"Savings"
]
print("-------FINANCE MANAGEMENT SYSTEM------")
income = float(input("Let us know your income: $"))
register_category: bool = True
expenses = dict()
while register_category:

option = input("Do you want to register an expense? y/n: ")
if option.upper() != "Y":
register_category = False
continue

for index, category in enumerate(categories):
print(f"{index + 1}. {category}")

option = int(input("Category: "))
if option > len(categories):
print("Error, fail on category input")
else:
print(f"Expense on {categories[option - 1]}")
amount = float(input("Expense amount: "))
expenses.update({categories[option - 1]: amount})

print("Registered epxenses: ")
print(expenses)
total_expense = sum(list(expenses.values()))
print(f"Total expense: {total_expense}" )

if total_expense - income == 0:
max_expense = max(list(expenses.values()))
max_index = list(expenses.values()).index(max_expense)
max_cat = list(expenses.keys())[max_index]
print(f"Reduce your expenses in {max_cat}")
elif total_expense - income > 0:
print("Improve your financial health")
else:
print("Congratulations!! You are saving money")


if __name__ == "__main__":
main()
10 changes: 10 additions & 0 deletions ShippingSystem/.idea/ShippingSystem.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ShippingSystem/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions ShippingSystem/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading