/// <summary> /// Initializes a new instance of the <see cref="CreditCard" /> class. /// </summary> public CreditCard( ) { owner = new CreditCardOwner("John Doe", "(000) 000-0000", "*****@*****.**"); IIN = "00000000000019"; Expiration = CurrentDate.Month.ToString("MM") + "/" + CurrentDate.Year; ValidCard = false; } //End CreditCard
} //End CreditCard (string) /// <summary> /// Initializes a copy instance of the <see cref="CreditCard"/> class. /// </summary> /// <param name="card">The card.</param> public CreditCard(CreditCard card) { owner = new CreditCardOwner( ); this.owner.Name = card.owner.Name; this.owner.PhoneNumber = card.owner.PhoneNumber; this.owner.EmailAddress = card.owner.EmailAddress; this.IIN = card.IIN; this.Expiration = card.Expiration; ValidCard = CheckExpiration(Expiration); } //End CreditCard (CreditCard)
} //End CreditCard (string) /// <summary> /// Initializes a new instance of the <see cref="CreditCard"/> class. /// </summary> /// <param name="iIN">The i in.</param> /// <exception cref="Exception">Invalid Card Number</exception> public CreditCard(string name, string phoneNumber, string emailAddress, string iIN, string expiration) { owner = new CreditCardOwner(name, phoneNumber, emailAddress); //Removes any unusable characters from card number for (int i = 0; i < iIN.Length; i++) { if (iIN [i].ToString( ).Contains(@" \][|}{+=_-)(*&^%$#@!`~:;<,>.?/")) { iIN.Remove(i, 1); i--; } } if (LuhnAlgorithm(iIN)) { //Set Card Number IIN = iIN; } //End if statement else { ValidCard = false; //Throw error message if card number or expiration is invalid throw new Exception("Invalid Card Number: " + iIN); } //End else statement if (CheckExpiration(expiration)) { ValidCard = true; //Set Expiration Expiration = expiration; } //End if statement else { ValidCard = false; Expiration = CurrentDate.Month + "/" + CurrentDate.Year; } //End else statement } //End CreditCard (string)