diff options
| author | mo <mo.khan@gmail.com> | 2019-06-09 21:30:34 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2019-06-09 21:30:34 -0600 |
| commit | d52f961c06d46bd87d96109f978ca3c6ae9e9687 (patch) | |
| tree | 31114ab2b5c6e7b5edf7b34e846b727c243a0bf2 /src | |
| parent | 77073fac44bff8f03b216c031d0c9125a2dac8cc (diff) | |
add program profile for Q3
Diffstat (limited to 'src')
| -rw-r--r-- | src/Q3/README.md | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/Q3/README.md b/src/Q3/README.md index 6f6ab07..6b7f0ac 100644 --- a/src/Q3/README.md +++ b/src/Q3/README.md @@ -37,6 +37,75 @@ and if it is valid, print the name of the company that offers that credit card n ``` 2. Description of the Code: + +The code implements the expected API as per the class diagram provided +in the assignment. I also included some additional private methods to +try to increase the readability of the code. The bulk of the logic for +the `Luhn` algorithm takes place in the `calculateSums` method. + +This method reverses the credit card number then loops through each +character. As it loops through each character it checks to see if the +current index is even or odd and applys the appropriate summing rules +for that index. + 3. Errors and Warnings: + +Length is too short: + +```bash +java -cp target/assignment2*.jar ca.mokhan.comp268.App 3 +Enter credit card #: +1334 +1334 in invalid +``` + +Length is too long: + +```bash +Enter credit card #: +41111111111111111 +41111111111111111 in invalid +```` + +Invalid card type: + +```bash +Enter credit card #: +1234567890123456 +1234567890123456 in invalid +``` + 4. Sample Input and Output: + +Valid AMEX card #: + +```bash +Enter credit card #: +378282246310005 +378282246310005 is offerred by American Express +``` + +Valid Discover card #: + +```bash +Enter credit card #: +6011111111111117 +6011111111111117 is offerred by Discover +``` + +Valid MasterCard #: + +```bash +Enter credit card #: +5555555555554444 +5555555555554444 is offerred by MasterCard +``` + +Valid Visa card #: + +```bash +Enter credit card #: +4012888888881881 +4012888888881881 is offerred by Visa +``` 5. Discussion: |
