Category and SubCategory System
We need to pass the file name as argument.
- Java version greater than or equal 1.7
- Gradle
- commons-collections
- Junit
- Read each line from the file
- And get the category and subcategory
- Once you get category, sub category add these to Category object
- Check for the duplicates if not present then add the category object to category list
- By using Category list print the categoryCountMap and categories to console
- Run from the IDE Run as java application CategoryDemo by passing the filename as argument
OR
-
gradle clean test buildJar - it will generate the jar file
java -jar CategoryDemo-1.0.jar 'inputfile'
e.g : java -jar CategoryDemo-1.0.jar C:\ValidCategeroyset.txt
####File Input:
- PERSON Bob Jones
- PLACE Washington
- PERSON Mary
- COMPUTER Mac
- PERSON Bob Jones
- OTHER Tree
- ANIMAL Dog
- PLACE Texas
- FOOD Steak
- ANIMAL Cat
####Output:
Category Count
PERSON 2
PLACE 2
ANIMAL 2
COMPUTER 1
OTHER 1
PERSON Bob Jones
PLACE Washington
PERSON Mary
COMPUTER Mac
OTHER Tree
ANIMAL Dog
PLACE Texas
ANIMAL Cat
###Code Coverage:
Run the below command to get the code coverage report
gradle clean test jacocoTestReport
###PMD: Verified the code with PMD check and not found any critical violations(except the one which are related to System.out.println(), which is required in this program)