First
This commit is contained in:
60
Credit_Card_Validator/credit-card.py
Normal file
60
Credit_Card_Validator/credit-card.py
Normal file
@ -0,0 +1,60 @@
|
||||
class CreditCard:
|
||||
def __init__(self, card_number):
|
||||
self.card_number = "the card number"
|
||||
self.card_type = "a string"
|
||||
self.valid = "a boolean"
|
||||
|
||||
#Create and add your method called `determine_card_type` to the CreditCard class here:
|
||||
def determine_card_type(self):
|
||||
pass
|
||||
|
||||
#Create and add your method called `check_length` to the CreditCard class here:
|
||||
def check_length(self):
|
||||
pass
|
||||
|
||||
#Create and add your method called 'validate' to the CreditCard class here:
|
||||
def validate(self):
|
||||
pass
|
||||
|
||||
|
||||
#do not modify assert statements
|
||||
|
||||
cc = CreditCard('9999999999999999')
|
||||
|
||||
assert cc.valid == False, "Credit Card number cannot start with 9"
|
||||
assert cc.card_type == "INVALID", "99... card type is INVALID"
|
||||
|
||||
cc = CreditCard('4440')
|
||||
|
||||
assert cc.valid == False, "4440 is too short to be valid"
|
||||
assert cc.card_type == "INVALID", "4440 card type is INVALID"
|
||||
|
||||
cc = CreditCard('5515460934365316')
|
||||
|
||||
assert cc.valid == True, "Mastercard is Valid"
|
||||
assert cc.card_type == "MASTERCARD", "card_type is MASTERCARD"
|
||||
|
||||
cc = CreditCard('6011053711075799')
|
||||
|
||||
assert cc.valid == True, "Discover Card is Valid"
|
||||
assert cc.card_type == "DISCOVER", "card_type is DISCOVER"
|
||||
|
||||
cc = CreditCard('379179199857686')
|
||||
|
||||
assert cc.valid == True, "AMEX is Valid"
|
||||
assert cc.card_type == "AMEX", "card_type is AMEX"
|
||||
|
||||
cc = CreditCard('4929896355493470')
|
||||
|
||||
assert cc.valid == True, "Visa Card is Valid"
|
||||
assert cc.card_type == "VISA", "card_type is VISA"
|
||||
|
||||
cc = CreditCard('4329876355493470')
|
||||
|
||||
assert cc.valid == False, "This card does not meet mod10"
|
||||
assert cc.card_type == "INVALID", "card_type is INVALID"
|
||||
|
||||
cc = CreditCard('339179199857685')
|
||||
|
||||
assert cc.valid == False, "Validates mod10, but invalid starting numbers for AMEX"
|
||||
assert cc.card_type == "INVALID", "card_type is INVALID"
|
Reference in New Issue
Block a user