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