44import enums .Field ;
55import input .CustomCollection ;
66import input .InputManager ;
7+ import output .FileDataWriter ;
78import sorting .MergeSortDefaultStrategy ;
89import sorting .MergeSortDynamicStrategy ;
910import sorting .SortingManager ;
@@ -15,43 +16,49 @@ public class AppController {
1516 private final InputManager inputManager = new InputManager ();
1617 private final CustomCollection <Client > fullList = new CustomCollection <>();
1718 private final SortingManager sortingManager = new SortingManager ();
19+ private final FileDataWriter fileDataWriter = new FileDataWriter ();
20+ ConcurrentCounter concurrentCounter = new ConcurrentCounter ();
1821
1922 public void startDefaultSorting (){
2023 sortingManager .setStrategy (new MergeSortDefaultStrategy ());
2124 sortingManager .getCurrentStrategy ().sort (fullList );
22- showAllClients ();
25+ showAndWriteAllClients ();
2326 }
2427
2528 public void startEvenIdsSorting (){
2629 sortingManager .setStrategy (new MergeSortDefaultStrategy ());
2730 sortingManager .getCurrentStrategy ().sortEvenValuesOnly (fullList );
28- showAllClients ();
31+ showAndWriteAllClients ();
2932 }
3033
3134 public void startDynamicSorting (Field field ){
3235 sortingManager .setStrategy (new MergeSortDynamicStrategy (field , true ));
3336 sortingManager .getCurrentStrategy ().sort (fullList );
34- showAllClients ();
37+ showAndWriteAllClients ();
3538 }
3639
3740 public CustomCollection <Client > getFullList () {
3841 return fullList ;
3942 }
4043
41- public void showAllClients (){
44+ public void showAndWriteAllClients (){
4245 for (Client client : fullList ){
4346 System .out .println (client );
47+ fileDataWriter .writeDataToFile (client + "\n " );
4448 }
49+ fileDataWriter .writeDataToFile ("\n " );
4550 }
4651
4752 public void startFileReaderStrategy (String path ){
4853 inputManager .setStrategy (inputManager .createFileStrategy (path ));
4954 try {
5055 CustomCollection <Client > fromFileList = inputManager .loadData ();
56+ int countOfAlexes = concurrentCounter .countAlexes (fromFileList );
5157 fullList .addAll (fromFileList );
5258 for (Client client : fromFileList ){
5359 System .out .println (client );
5460 }
61+ System .out .println ("Добавлено Алексеев: " + countOfAlexes );
5562 } catch (IOException e ) {
5663 throw new RuntimeException (e );
5764 }
@@ -61,10 +68,12 @@ public void startManualInputStrategy(){
6168 inputManager .setStrategy (inputManager .createManualStrategy ());
6269 try {
6370 CustomCollection <Client > manualList = inputManager .loadData ();
71+ int countOfAlexes = concurrentCounter .countAlexes (manualList );
6472 fullList .addAll (manualList );
6573 for (Client client : manualList ){
6674 System .out .println (client );
6775 }
76+ System .out .println ("Добавлено Алексеев: " + countOfAlexes );
6877 } catch (IOException e ) {
6978 throw new RuntimeException (e );
7079 }
@@ -74,10 +83,12 @@ public void startRandomDataStrategy(int count){
7483 inputManager .setStrategy (inputManager .createRandomStrategy (count ));
7584 try {
7685 CustomCollection <Client > randomList = inputManager .loadData ();
86+ int countOfAlexes = concurrentCounter .countAlexes (randomList );
7787 fullList .addAll (randomList );
7888 for (Client client : randomList ){
7989 System .out .println (client );
8090 }
91+ System .out .println ("Добавлено Алексеев: " + countOfAlexes );
8192 } catch (IOException e ) {
8293 throw new RuntimeException (e );
8394 }
0 commit comments