-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSimpleBankSystem.py
More file actions
27 lines (21 loc) · 834 Bytes
/
SimpleBankSystem.py
File metadata and controls
27 lines (21 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from typing import List
class Bank:
def __init__(self, balance: List[int]):
self.balance = balance
self.n = len(self.balance)
def transfer(self, account1: int, account2: int, money: int) -> bool:
if account1 > self.n or account2 > self.n or self.balance[account1 - 1] < money:
return False
self.balance[account1 - 1] -= money
self.balance[account2 - 1] += money
return True
def deposit(self, account: int, money: int) -> bool:
if account > self.n:
return False
self.balance[account - 1] += money
return True
def withdraw(self, account: int, money: int) -> bool:
if account > self.n or self.balance[account - 1] < money:
return False
self.balance[account - 1] -= money
return True