Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alipbudiman/521713d755dec523e9b9dfdf410052f5 to your computer and use it in GitHub Desktop.
Save alipbudiman/521713d755dec523e9b9dfdf410052f5 to your computer and use it in GitHub Desktop.
## contoh implementasi sederhana penggunaan data arry untuk login di atm
storageATM = {}
cardIDBlockServer = {}
cardIDDatabaseServer = {
"123456":"1111",
"6666":"9999",
"3232":"24235346"
}
def InsertCard():
cardID = str(input("input your card id ::: "))
if cardID in cardIDDatabaseServer:
data = {
"cardID":cardID,
"status":200
}
return data
else:
data = {
"cardID":cardID,
"status":400
}
return data
def Login(cardID):
pincode = str(input("enter your pincode ::: "))
if cardIDDatabaseServer[cardID] == pincode:
return 200
else:
return 400
atm = 1
while atm == 1:
res = InsertCard()
cardIDBlockServer[res["cardID"]] = 0
if cardIDBlockServer[res["cardID"]] != 3:
if res["status"] == 200:
atm = 2
CardIDClient = res["cardID"]
while atm == 2:
res = Login(CardIDClient)
if res == 200:
print("MAIN MENU\n > Transfer\n > Chas out")
atm = 0
else:
cardIDBlockServer[CardIDClient] += 1
if cardIDBlockServer[CardIDClient] != 3:
print(f"wrong pin code!!")
else:
print("your card is blocked, please contac CS")
atm = 0
elif res["status"] == 400:
id = res["cardID"]
print(f"id card :: {id} | wrong id card number")
else:
print("your card is blocked, please contac CS")
atm = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment