Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group #3 Changes #18

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
12 changes: 12 additions & 0 deletions application/donatingService.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class DonatingService:

def __init__(self):
return self

def donate_from_user1_to_user2(self, repository: Repository, user1: User, user2: User, amount: float):
balance_1 = repository.getBalance(user=user1)
balance_2 = repository.getBalance(user=user2)
new_balance1 = balance_1 - amount
new_balance2 = balance_1 + amount
repository.updateBankAccount(user=user1, new_balance=new_balance1)
repository.updateBankAccount(user=user2, new_balance=new_balance2)
Empty file added application/loaningService.py
Empty file.
12 changes: 12 additions & 0 deletions application/withdrawingService.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from domain.repository import Repository
from domain.user import User

class WithdrawingService:

def __init__(self):
return self

def withdraw_from_user(self, repository: Repository, user: User, amount: float):
balance = repository.getBalance(user=user)
new_balance = balance - amount
repository.updateBankAccount(user=user, new_balance=new_balance)
14 changes: 14 additions & 0 deletions domain/bankaccount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from user import User

class BankAccount:
_balance: float
_user: User
def __init__(self, user: User):
self._balance = 0
self._user = user
def getBalance(self):
return self._balance
def setBalance(self, new_balance: float):
self._balance = new_balance
def getUser(self):
return self._user
24 changes: 24 additions & 0 deletions domain/repository.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from abc import ABC, abstractmethod
from bankaccount import BankAccount
from user import User

class Repository(ABC):
@abstractmethod
def __init__():
pass

@abstractmethod
def addBankAccount(self, BankAccount):
pass

@abstractmethod
def getBankAccount(self, user: User):
pass

@abstractmethod
def updateBankAccount(self, user: User, new_balance: float):
pass

@abstractmethod
def getBalance(self, user: User):
pass
9 changes: 9 additions & 0 deletions domain/user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class User:
_name: str
def __init__(self, name: str):
self._name = name
def getName(self):
return self._name
def setName(self, name):
self._name = name

15 changes: 15 additions & 0 deletions infrastructure/sqlrepository.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from domain.repository import Repository

class SqLRepository(Repository):

def addBankAccount(self, BankAccount):
pass

def getBankAccount(self, user: User):
pass

def updateBankAccount(self, user: User, new_balance: float):
pass

def getBalance(self, user: User):
pass