Skip to content

pedro-foobar/javaExercise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Card Fraud Detector

Consider the following credit card fraud detection algorithm: A credit card transaction is comprised of the following elements; hashed credit card number timestamp - of format 'year-month-dayThour:minute:second' price - of format 'dollars.cents'

Transactions are to be received as a comma separated string of elements eg. '10d7ce2f43e35fa57d1bbf8b1e2, 2014-04-29T13:15:54, 10.00'

A credit card will be identified as fraudulent if the sum of prices for a unique hashed credit card number, for a given day, exceeds the price threshold T.

Write a method on a class, which, when given a list transactions, a date and a price threshold T, returns a list of hashed credit card numbers that have been identified as fraudulent for that day. Feel free to create any additional classes you need to support the design of your solution.

Getting Started

These instructions will get you a copy of the cardFraudDetector up and running on your local machine for development and testing purposes.

Prerequisites

Java 1.8

Maven

Build

open a command console into the cardFraudDetector folder and run the following

mvn clean package

this will run all the unit tests then compile the class file and build the jar file under /target directory

Running the tests

automated tests are under /src/test/java/com/cardfraud/AppTest.java they can be run with

mvn test

Running the application

the cardFraudDetector-1.jar under target folder has to be run with 3 arguments : a file containing a list of transaction ( see transaction_file_example file under cardFraudDetector folder) an amount threshold a date

for example : open a command console into the cardFraudDetector folder and run the following

java -jar .\target\cardFraudDetector-1.jar transaction_file_example 10 2014-04-29

main class is DetectionRunner.java

feel free to run the app with other files and play with the arguments.

Note that you can import the project as a maven project into eclipse and run the tests with Junit

Further dev idea

Refactor code according to S.O.L.I.D principle

todo

adapt multithread version reading multiple file simultaneously

todo

About

code challenge with java8 and maven

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages