-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bank-account: formatting bank-account: formatting bank-account: fixing travis issues bank-account: fixing travis issues bank-account: Fixing Travis Issue
- Loading branch information
1 parent
8cfd2fd
commit 1998c23
Showing
3 changed files
with
61 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
import threading | ||
|
||
class BankAccount(object): | ||
def __init__(self): | ||
pass | ||
|
||
def getBalance(self): | ||
pass | ||
|
||
def open(self): | ||
pass | ||
|
||
def deposit(self, amount): | ||
pass | ||
class BankAccount(object): | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def withdraw(self, amount): | ||
pass | ||
def getBalance(self): | ||
pass | ||
|
||
def close(self): | ||
pass | ||
def open(self): | ||
pass | ||
|
||
def deposit(self, amount): | ||
pass | ||
|
||
def withdraw(self, amount): | ||
pass | ||
|
||
def close(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,44 @@ | ||
import threading | ||
|
||
class BankAccount(object): | ||
def __init__(self): | ||
self.lock = threading.Lock() | ||
|
||
def getBalance(self): | ||
self.lock.acquire() | ||
if (self.open == True): | ||
self.lock.release() | ||
return self.balance | ||
else: | ||
self.lock.release() | ||
raise Exception | ||
|
||
def getBalance(self): | ||
self.lock.acquire() | ||
if (self.open == True): | ||
self.lock.release() | ||
return self.balance | ||
else: | ||
self.lock.release() | ||
raise Exception | ||
|
||
def open(self): | ||
self.lock.acquire() | ||
self.balance = 0 | ||
self.open = True | ||
self.lock.release() | ||
|
||
def deposit(self, amount): | ||
self.lock.acquire() | ||
if (self.open == True and amount>0): | ||
self.balance += amount | ||
self.lock.release() | ||
else: | ||
self.lock.release() | ||
raise Exception | ||
|
||
|
||
def withdraw(self, amount): | ||
self.lock.acquire() | ||
if (self.open == True and self.balance >= amount and amount>0): | ||
self.balance -= amount | ||
self.lock.release() | ||
else: | ||
self.lock.release() | ||
raise Exception | ||
|
||
def close(self): | ||
self.lock.acquire() | ||
self.open = False | ||
self.lock.release() | ||
class BankAccount(object): | ||
def __init__(self): | ||
self.lock = threading.Lock() | ||
|
||
def getBalance(self): | ||
self.lock.acquire() | ||
if (self.open is True): | ||
self.lock.release() | ||
return self.balance | ||
else: | ||
self.lock.release() | ||
raise Exception | ||
|
||
def open(self): | ||
self.lock.acquire() | ||
self.balance = 0 | ||
self.open = True | ||
self.lock.release() | ||
|
||
def deposit(self, amount): | ||
self.lock.acquire() | ||
if (self.open is True and amount > 0): | ||
self.balance += amount | ||
self.lock.release() | ||
else: | ||
self.lock.release() | ||
raise Exception | ||
|
||
def withdraw(self, amount): | ||
self.lock.acquire() | ||
if (self.open is True and self.balance >= amount and amount > 0): | ||
self.balance -= amount | ||
self.lock.release() | ||
else: | ||
self.lock.release() | ||
raise Exception | ||
|
||
def close(self): | ||
self.lock.acquire() | ||
self.open = False | ||
self.lock.release() |