mirror of
https://github.com/wahyd4/afterpay-creditcard.git
synced 2026-08-08 21:06:52 +10:00
Update readme
This commit is contained in:
@@ -28,15 +28,15 @@ Then go to `build/reports/jacoco/test/html/index.html` to see the result.
|
||||
|
||||
The `fraudulentCreditCards` method in `com.github.wahyd4.creditcard.service.FraudChecker` receives list of transactions string and threshold to calculate all the credit cards which exceed the money threshold.
|
||||
|
||||
1. First, all the transaction string records will be parsed to a TransactionEntry object.
|
||||
2. Group all the transactions by hashed credit card id, the value of the key is all the records for that hashed id.
|
||||
3. Calculate the total money for every credit card to see if it exceeds the threshold, it will based on the sliding window.
|
||||
4. Return all the matched hashed credit cards as list.
|
||||
1. First, all the transaction string records will be parsed into a TransactionEntry object.
|
||||
2. Then loops the entries, it groups all the transactions by hashed credit card id, the value of the key is all the records for that hashed id.
|
||||
3. During this time, the program analyses all the records for the specific card comes from the current entry. If the records overs one `24` hours windows, then only keep the most recent `24` hours records. If the card has been marked as fraudulent, then it will skipped.
|
||||
4. Calculates the total amount against the most recent `24` hours records, if the value greater than the threshold then mark the card as `fraudulent` and put it into the `map`.
|
||||
5. Returns all the matched hashed credit cards as a list.
|
||||
|
||||
## Assumptions
|
||||
|
||||
* The `24` hour sliding window means, from the very latest record time we have for a credit card to its 24 hours ago.
|
||||
And each credit card may have different time sliding windows based on their latest transaction time.
|
||||
* `a sequence of transactions in chronological order` means the first item in the list is the oldest record.
|
||||
|
||||
## Highlights
|
||||
|
||||
|
||||
Reference in New Issue
Block a user