- Task
- How to build
- File Structure
- Dependencies
- Technologies
- Information and links
- Tests coverage report
Write an interactive application (reads System.in) that reads lines (strings) from standard-input one by one and counts:
Part-1:
- the number of unique characters in the current line
- how many times the particular character appears in the global text
- how many vowels and consonants in the current line
- how many continuous consonant sequences in the line
- for each symbol the minimal and maximal index of it in the line
Part-2:
It is expected that a string with the same character sequence may be passed several times to the method. Since the counting operation can be time-consuming, the method should cache the results, so that when the method is given a string previously encountered, it will simply retrieve the stored result. Use collections and maps where appropriate. Chose appropriate cache eviction policy and implement it. Externalize cache config, etc.. into Maven's resource dir application.properties file. Implement printing like on this example:
>: askldjfask; fsdf asd;klfj asdf
Number of unique characters in the current line: 9
Vowels: 4
Consonants: 21
Continuous consonant sequences: 6
+------------+------------+------------+------------+------------+
| Symbol | Line | Global | Min index | Max index |
+------------+------------+------------+------------+------------+
| a | 4 | 7 | 0 | 26 |
| s | 5 | 8 | 1 | 27 |
| k | 3 | 5 | 2 | 21 |
| l | 2 | 3 | 3 | 22 |
| d | 4 | 7 | 4 | 28 |
| j | 2 | 4 | 5 | 24 |
| f | 5 | 8 | 6 | 29 |
| ; | 2 | 2 | 10 | 20 |
| | 3 | 5 | 11 | 25 |
+------------+------------+------------+------------+------------+
>:
Make sure Java Development Kit (JDK) and Maven tool installed on your machine.
There are two options how to build project:
-
Windows:
- double-click on
make.bat
:
- double-click on
- or use Command Prompt: navigate to project's root folder and type
make.bat
command:
-
or use
mvnw.cmd package
command in Terminal (Maven Wrapper) -
or use
mvn package
command in Terminal (Maven)
-
Linux/MacOS:
- execute
make.sh
script file by using./make.sh
command:
- execute
-
or use
./mvnw package
command in Terminal (Maven Wrapper) -
or use
mvn package
command in Terminal with Maven
make.bat
and make.sh
will create a dist
folder with application execution jar, batch + bash files and _README file for users.
├── src
│ ├── main
│ │ └── java
| | |-- ua/com/foxminded/collections
| | | └── Main.java
| | |
│ │ │── ua/com/foxminded/collections/cache
| | | |-- Cache.java
│ │ │ └── CacheableCharactersCounter.java
│ │ │
│ │ │── ua/com/foxminded/collections/context
│ │ │ └── Context.java
│ │ │
│ │ │── ua/com/foxminded/collections/table
| | | |-- TableCreator.java
│ │ │ └── TableData.java
│ │ │
│ │ └── ua/com/foxminded/collections/text
│ │ └── CaractersCounter.java
│ │
│ └── test
│ └── java
| |-- ua/com/foxminded/collections
| | └──~~~~ MainTest.java
| |
│ │── ua/com/foxminded/collections/cache
| | |-- CacheTest.java
│ │ └── CacheableCharactersCounterTest.java
│ │
│ │── ua/com/foxminded/collections/context
│ │ └── ContextTest.java
│ │
│ │── ua/com/foxminded/collections/table
| | |-- TableCreatorTest.java
│ │ └── TableDataTest.java
| │
│ └── ua/com/foxminded/collections/text
│ └── CaractersCounterTest.java
|
├── docs
│ └── img
│ └── *.png
│-- target
├── .gitignore
├── make.bat
├── make.sh
|-- _README.md
└── README.md
- JUnit Platform: junit-platform-console-standalone-1.6.0 (download)
- JUnit TestEngine API: junit-jupiter-api-5.6.0 (download)
- Mockito mocking framework for unit tests: mockito-all-1.10.19 (download)
- JaCoCo - Java Code Coverage Library 0.8.5 (download)
- Maven Wrapper (download)
- Maven Shade Plugin: maven-shade-plugin-3.2.3 (download)
- Java EE 1.8
- Junit 5
- Maven