|
1 | | -import userInterface.MenuManager; |
| 1 | +import dto.Client; |
| 2 | +import input.CustomCollection; |
| 3 | +import input.InputManager; |
| 4 | +import input.Strategy.FileReaderStrategy; |
| 5 | +import input.Strategy.ManualInputReaderStrategy; |
| 6 | +import input.Strategy.RandomDataGeneratorStrategy; |
2 | 7 |
|
3 | | -import java.util.stream.IntStream; |
| 8 | +import java.io.IOException; |
| 9 | +import java.io.PrintStream; |
| 10 | +import java.nio.charset.StandardCharsets; |
4 | 11 |
|
5 | 12 | public class App { |
6 | | - public static void main(String[] args) { |
7 | | - MenuManager menuManager = new MenuManager(); |
| 13 | + public static void main(String[] args) throws IOException { |
| 14 | + System.setOut(new PrintStream(System.out, true, StandardCharsets.UTF_8)); |
| 15 | +//// |
| 16 | +//// System.out.println("=== ТЕСТ FileReader ==="); |
| 17 | +//// |
| 18 | +//// try { |
| 19 | +//// FileReaderStrategy reader = new FileReaderStrategy("test_clients.txt"); |
| 20 | +//// CustomCollection<Client> clients = reader.getData(); |
| 21 | +//// |
| 22 | +//// System.out.println("\n=== РЕЗУЛЬТАТ ==="); |
| 23 | +//// System.out.println("Загружено клиентов: " + clients.size()); |
| 24 | +//// System.out.println("Содержимое:"); |
| 25 | +//// |
| 26 | +//// int i = 1; |
| 27 | +//// for (Client client : clients) { |
| 28 | +//// System.out.println(i + ". " + client); |
| 29 | +//// i++; |
| 30 | +//// } |
| 31 | +//// |
| 32 | +//// } catch (Exception e) { |
| 33 | +//// System.out.println("ФАТАЛЬНАЯ ОШИБКА: " + e.getMessage()); |
| 34 | +//// e.printStackTrace(); |
| 35 | +//// } |
| 36 | +//// |
| 37 | +//// System.out.println("=== КОНЕЦ ТЕСТА === \n"); |
| 38 | +//// |
| 39 | +//// System.out.println("=== ТЕСТ RandomDataGenerator ==="); |
| 40 | +//// |
| 41 | +//// // Тест 1: Базовая генерация |
| 42 | +//// RandomDataGeneratorStrategy generator = new RandomDataGeneratorStrategy(5); |
| 43 | +//// CustomCollection<Client> clients = generator.getData(); |
| 44 | +//// |
| 45 | +//// System.out.println("Сгенерировано: " + clients.size() + " клиентов"); |
| 46 | +//// clients.forEach(client -> System.out.println(" - " + client)); |
| 47 | +//// |
| 48 | +//// // Тест 2: С уникальными параметрами |
| 49 | +//// System.out.println("\n=== Тест с кастомным диапазоном ==="); |
| 50 | +//// RandomDataGeneratorStrategy generator2 = new RandomDataGeneratorStrategy(3); |
| 51 | +//// CustomCollection<Client> clients2 = generator2.getData(); |
| 52 | +//// |
| 53 | +//// clients2.forEach(client -> |
| 54 | +//// System.out.println(" - " + client.getName() + ", ID: " + client.getIdNumber())); |
| 55 | +//// |
| 56 | +//// System.out.println("=== КОНЕЦ ТЕСТА ==="); |
| 57 | +// |
| 58 | +// System.out.println("=== ТЕСТ ManualInputReader ===\n"); |
| 59 | +// |
| 60 | +// ManualInputReaderStrategy reader = new ManualInputReaderStrategy(); |
| 61 | +// CustomCollection<Client> clients = reader.getData(); |
| 62 | +// |
| 63 | +// System.out.println("\n=== РЕЗУЛЬТАТ ==="); |
| 64 | +// System.out.println("Всего клиентов: " + clients.size()); |
| 65 | +// |
| 66 | +// if (!clients.isEmpty()) { |
| 67 | +// System.out.println("Список:"); |
| 68 | +// int i = 1; |
| 69 | +// for (Client client : clients) { |
| 70 | +// System.out.println(i + ". " + client); |
| 71 | +// i++; |
| 72 | +// } |
| 73 | +// } |
| 74 | +// System.out.println("=== КОНЕЦ ТЕСТА ==="); |
8 | 75 |
|
9 | | - menuManager.run(); |
| 76 | + InputManager inputManager = new InputManager(); |
| 77 | + inputManager.setStrategy(new FileReaderStrategy("test_clients.txt")); |
| 78 | + CustomCollection<Client> clients = inputManager.loadData(); |
| 79 | + clients.forEach(System.out::println); |
10 | 80 |
|
| 81 | + |
| 82 | +// inputManager.setStrategy(inputManager.createManualStrategy()); |
| 83 | +// CustomCollection<Client> clients2 = inputManager.loadData(); |
| 84 | +// clients2.forEach(System.out::println); |
11 | 85 | } |
12 | 86 | } |
| 87 | + |
0 commit comments