Models credit card information - it has accessors for #name and #number (both strings), and #expiry date. #validate throws an error if anything is missing, or if the expiry date is in the past. This is intended to be an abstract class - the subclasses WAStoreMasterCard and WAStoreVisaCard provide further validation.
ProtoObjectObjectWAStoreCreditCard
| expiry | name | number |
| instance | class |
|---|---|
| as yet unclassified | no messages
|
| expiry |
|---|
|
| name |
|---|
|
| number |
|---|
|
| as yet unclassified |
|---|
| expiry |
| expiry: aDate |
expiry _ aDate |
| name |
^ name |
| name: aString |
name _ aString |
| number |
^ number |
| number: aString |
number _ aString |
| validate |
name ifNil: [self error: 'You must provide the name of the credit card owner.']. number ifNil: [self error: 'You must provide a credit card number.']. expiry ifNil: [self error: 'You must provide an expiry date.']. expiry < Date today ifTrue: [self error: 'The expiry date must not be in the past']. |