APO-1 Add transfer allowance
This commit is contained in:
parent
37fb598867
commit
5a06fac6a6
@ -1,91 +1,95 @@
|
||||
import random
|
||||
import string
|
||||
|
||||
def PrintCardInfo(card):
|
||||
print("Owner's Name: " + card.account.name)
|
||||
print("Owner's Surname: " + card.account.surname)
|
||||
print("Card's Number: " + card.number)
|
||||
print("Card's Type: " + card.type)
|
||||
print("Card's PIN: " + card.pin)
|
||||
|
||||
def VerifyInvalidCard(card):
|
||||
if card.type not in ["ATM", "Credit", "Prepaid"]:
|
||||
return True
|
||||
return False
|
||||
|
||||
def VerifyOwner(card):
|
||||
inputPin = input("Enter PIN for this card, please: ")
|
||||
if inputPin == card.pin:
|
||||
card.wrongCounter = 0
|
||||
return True
|
||||
else:
|
||||
card.wrongCounter += 1
|
||||
if card.wrongCounter == 3:
|
||||
card.wrongCounter = 0
|
||||
card.blocked = True
|
||||
print("You've entered wrong PIN three times. This card will be blocked.")
|
||||
return False
|
||||
continueAnswer = input("Do you want to try again? (Y/N): ")
|
||||
if continueAnswer in ["Y", "y", "Yes", "yes"]:
|
||||
VerifyOwner(card)
|
||||
else:
|
||||
return False
|
||||
|
||||
def WithdrawMoney(amount, account):
|
||||
if amount > account.credit:
|
||||
print("You dont't have enough money on your account")
|
||||
return 0
|
||||
if amount%10 != 0:
|
||||
print("Enter multiple of 10")
|
||||
return 0
|
||||
account.subCredit(amount)
|
||||
out = ""
|
||||
while amount >= 200:
|
||||
amount -= 200
|
||||
out = out + "200 "
|
||||
while amount >= 100:
|
||||
amount -= 100
|
||||
out = out + "100 "
|
||||
while amount >= 50:
|
||||
amount -= 50
|
||||
out = out + "50 "
|
||||
while amount >= 20:
|
||||
amount -= 20
|
||||
out = out + "20 "
|
||||
while amount >= 10:
|
||||
amount -= 10
|
||||
out = out + "10 "
|
||||
print (out)
|
||||
return 1
|
||||
|
||||
def GeneratePrepaidPhoneCode(amount, operator, account):
|
||||
if amount > account.credit:
|
||||
print("You dont't have enough money on your account")
|
||||
return 0
|
||||
# print(operatorAPI(amount, operator))
|
||||
print(''.join(random.choices(string.ascii_uppercase + string.digits, k=14)))
|
||||
account.subCredit(amount)
|
||||
return 1
|
||||
|
||||
def DepositMoney(notes, account):
|
||||
amount = 0
|
||||
for note in notes:
|
||||
amount += int(note)
|
||||
account.addCredit(amount)
|
||||
return 1
|
||||
|
||||
def CheckAccount(account):
|
||||
print("Stored money: " + str(account.credit))
|
||||
return 1
|
||||
|
||||
def TransferMoney(accountFrom, accountTo, amount):
|
||||
if amount > accountFrom.credit:
|
||||
print("You dont't have enough money on your account")
|
||||
return 0
|
||||
accountFrom.subCredit(amount)
|
||||
accountTo.addCredit(amount)
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
|
||||
import random
|
||||
import string
|
||||
|
||||
def PrintCardInfo(card):
|
||||
print("Owner's Name: " + card.account.name)
|
||||
print("Owner's Surname: " + card.account.surname)
|
||||
print("Card's Number: " + card.number)
|
||||
print("Card's Type: " + card.type)
|
||||
print("Card's PIN: " + card.pin)
|
||||
|
||||
def VerifyInvalidCard(card):
|
||||
if card.type not in ["ATM", "Credit", "Prepaid"]:
|
||||
return True
|
||||
return False
|
||||
|
||||
def VerifyOwner(card):
|
||||
inputPin = input("Enter PIN for this card, please: ")
|
||||
if inputPin == card.pin:
|
||||
card.wrongCounter = 0
|
||||
return True
|
||||
else:
|
||||
card.wrongCounter += 1
|
||||
if card.wrongCounter == 3:
|
||||
card.wrongCounter = 0
|
||||
card.blocked = True
|
||||
print("You've entered wrong PIN three times. This card will be blocked.")
|
||||
return False
|
||||
continueAnswer = input("Do you want to try again? (Y/N): ")
|
||||
if continueAnswer in ["Y", "y", "Yes", "yes"]:
|
||||
VerifyOwner(card)
|
||||
else:
|
||||
return False
|
||||
|
||||
def WithdrawMoney(amount, account):
|
||||
if amount > account.credit:
|
||||
print("You dont't have enough money on your account")
|
||||
return 0
|
||||
if amount%10 != 0:
|
||||
print("Enter multiple of 10")
|
||||
return 0
|
||||
account.subCredit(amount)
|
||||
out = ""
|
||||
while amount >= 200:
|
||||
amount -= 200
|
||||
out = out + "200 "
|
||||
while amount >= 100:
|
||||
amount -= 100
|
||||
out = out + "100 "
|
||||
while amount >= 50:
|
||||
amount -= 50
|
||||
out = out + "50 "
|
||||
while amount >= 20:
|
||||
amount -= 20
|
||||
out = out + "20 "
|
||||
while amount >= 10:
|
||||
amount -= 10
|
||||
out = out + "10 "
|
||||
print (out)
|
||||
return 1
|
||||
|
||||
def GeneratePrepaidPhoneCode(amount, operator, account):
|
||||
if amount > account.credit:
|
||||
print("You dont't have enough money on your account")
|
||||
return 0
|
||||
# print(operatorAPI(amount, operator))
|
||||
print(''.join(random.choices(string.ascii_uppercase + string.digits, k=14)))
|
||||
account.subCredit(amount)
|
||||
return 1
|
||||
|
||||
def DepositMoney(notes, account):
|
||||
amount = 0
|
||||
for note in notes:
|
||||
amount += int(note)
|
||||
account.addCredit(amount)
|
||||
return 1
|
||||
|
||||
def CheckAccount(account):
|
||||
print("Stored money: " + str(account.credit))
|
||||
return 1
|
||||
|
||||
def TransferMoney(accountFrom, accountTo, amount):
|
||||
if amount > accountFrom.credit:
|
||||
print("You dont't have enough money on your account")
|
||||
return 0
|
||||
if accountTo.acceptTransfers:
|
||||
accountFrom.subCredit(amount)
|
||||
accountTo.addCredit(amount)
|
||||
return 1
|
||||
else:
|
||||
print("Reciever do not allow transfers")
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user