refactor(creation): move fill settings out of application state

- remove custom data collection and file path from AppState
- add FillStrategy abstraction for collection creation
- add ManualFillSettings and ManualFillStrategy
- add FileFillSettings and FileFillStrategy
- move collection size input into reusable CollectionSizeInputWindow
- update ManualDataSettingsWindow to manage its own editing state
This commit is contained in:
2026-08-30 23:46:53 +04:00
parent 79a0f7b3c2
commit f7ac87c3f2
7 changed files with 237 additions and 152 deletions
@@ -7,13 +7,9 @@ import ru.project.student.Student;
public class AppState { public class AppState {
private MyList<Student> mainCollection; private MyList<Student> mainCollection;
private MyList<Student> customDataCollection;
private String currentFilePath;
public AppState() { public AppState() {
this.mainCollection = new MyLinkedList<>(); this.mainCollection = new MyLinkedList<>();
this.customDataCollection = new MyLinkedList<>();
this.currentFilePath = null;
} }
public MyList<Student> getMainCollection() { public MyList<Student> getMainCollection() {
@@ -23,21 +19,4 @@ public class AppState {
public void setMainCollection(MyList<Student> currentCollection) { public void setMainCollection(MyList<Student> currentCollection) {
this.mainCollection = currentCollection; this.mainCollection = currentCollection;
} }
public MyList<Student> getCustomDataCollection() {
return customDataCollection;
}
public void setCustomDataCollection(MyList<Student> customDataCollection) {
this.customDataCollection = customDataCollection;
}
public String getCurrentFilePath() {
return currentFilePath;
}
public void setCurrentFilePath(String currentFilePath) {
this.currentFilePath = currentFilePath;
}
} }
@@ -0,0 +1,51 @@
package ru.project.ui.common;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import java.util.function.Consumer;
public class CollectionSizeInputWindow {
private final WindowBasedTextGUI gui;
private final Integer currentSize;
private final Consumer<Integer> onSizeEntered;
public CollectionSizeInputWindow(
WindowBasedTextGUI gui, Integer currentSize, Consumer<Integer> onSizeEntered) {
this.gui = gui;
this.currentSize = currentSize;
this.onSizeEntered = onSizeEntered;
}
public void showModal() {
InputValueWindow window =
new InputValueWindow(
gui,
"Размер коллекции",
"Введите размер коллекции:",
currentSize != null && currentSize > 0 ? String.valueOf(currentSize) : null,
this::handleSizeEntered);
window.showModal();
}
private boolean handleSizeEntered(String value) {
try {
int size = Integer.parseInt(value);
if (size <= 0) {
MessageWindow.showModal(gui, "Размер должен быть больше 0.");
return false;
}
onSizeEntered.accept(size);
return true;
} catch (NumberFormatException e) {
MessageWindow.showModal(gui, "Введите целое число.");
return false;
}
}
}
@@ -5,94 +5,75 @@ import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.LinearLayout; import com.googlecode.lanterna.gui2.LinearLayout;
import com.googlecode.lanterna.gui2.Panel; import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI; import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import ru.project.collection.MyLinkedList;
import ru.project.collection.MyList;
import ru.project.model.AppState; import ru.project.model.AppState;
import ru.project.student.Student;
import ru.project.ui.base.BaseModalWindow; import ru.project.ui.base.BaseModalWindow;
import ru.project.ui.common.InputValueWindow;
import ru.project.ui.common.MessageWindow; import ru.project.ui.common.MessageWindow;
import ru.project.ui.creation.manual.CustomDataSettingsWindow; import ru.project.ui.creation.file.FileDataSettingsWindow;
import ru.project.ui.creation.file.FileFillSettings;
import ru.project.ui.creation.file.FileFillStrategy;
import ru.project.ui.creation.manual.ManualDataSettingsWindow;
import ru.project.ui.creation.manual.ManualFillSettings;
import ru.project.ui.creation.manual.ManualFillStrategy;
public class CreateCollectionMenu extends BaseModalWindow { public class CreateCollectionMenu extends BaseModalWindow {
private int collectionSize; private final AppState state;
private FillMethod selectedFillMethod;
private FillMethod selectedFillMethod;
private FillStrategy fillStrategy;
private final Label sizeLabel;
private final Label fillMethodLabel; private final Label fillMethodLabel;
private final CustomDataSettingsWindow customDataSettingsWindow; private final ManualDataSettingsWindow manualDataSettingsWindow;
private final FileDataSettingsWindow fileDataSettingsWindow;
public CreateCollectionMenu(WindowBasedTextGUI gui, AppState state) { public CreateCollectionMenu(WindowBasedTextGUI gui, AppState state) {
super("Создание новой коллекции", gui); super("Создание новой коллекции", gui);
collectionSize = 0; this.state = state;
selectedFillMethod = FillMethod.CUSTOM; this.selectedFillMethod = FillMethod.CUSTOM;
this.fillStrategy = null;
customDataSettingsWindow = new CustomDataSettingsWindow(gui, state, () -> collectionSize); this.manualDataSettingsWindow = new ManualDataSettingsWindow(gui, this::setManualFillStrategy);
this.fileDataSettingsWindow = new FileDataSettingsWindow(gui, this::setFileFillStrategy);
Panel panel = new Panel(); Panel panel = new Panel();
panel.setLayoutManager(new LinearLayout()); panel.setLayoutManager(new LinearLayout());
sizeLabel = new Label("Размер: не задан");
fillMethodLabel = new Label("Способ заполнения: " + getFillMethodName(selectedFillMethod)); fillMethodLabel = new Label("Способ заполнения: " + getFillMethodName(selectedFillMethod));
panel.addComponent(sizeLabel);
panel.addComponent(fillMethodLabel); panel.addComponent(fillMethodLabel);
panel.addComponent(new Button("Задать размер", this::showCollectionSizeInputValueWindow));
panel.addComponent(new Button("Выбрать способ заполнения", this::selectFillMethod)); panel.addComponent(new Button("Выбрать способ заполнения", this::selectFillMethod));
panel.addComponent( panel.addComponent(
new Button("Настроить текущий способ заполнения", this::setupCurrentFillMethod)); new Button("Настроить текущий способ заполнения", this::setupCurrentFillMethod));
panel.addComponent(new Button("Создать новую коллекцию", () -> updateMainCollection(state))); panel.addComponent(new Button("Создать новую коллекцию", this::updateMainCollection));
panel.addComponent(new Button("Выйти", this::close)); panel.addComponent(new Button("Выйти", this::close));
setComponent(panel); setComponent(panel);
} }
private void showCollectionSizeInputValueWindow() { private void setManualFillStrategy(ManualFillSettings settings) {
InputValueWindow window = fillStrategy = new ManualFillStrategy(settings);
new InputValueWindow(
gui,
"Размер коллекции",
"Введите размер коллекции:",
collectionSize > 0 ? String.valueOf(collectionSize) : null,
this::handleSizeEntered);
window.showModal();
} }
private boolean handleSizeEntered(String value) { private void setFileFillStrategy(FileFillSettings settings) {
try { fillStrategy = new FileFillStrategy(settings);
int enteredSize = Integer.parseInt(value);
if (enteredSize <= 0) {
MessageWindow.showModal(gui, "Размер должен быть больше 0.");
return false;
}
collectionSize = enteredSize;
sizeLabel.setText("Размер: " + collectionSize);
return true;
} catch (NumberFormatException e) {
MessageWindow.showModal(gui, "Введите целое число.");
return false;
}
} }
// private void setRandomFillStrategy(RandomFillSettings settings) {
// fillStrategy = new RandomFillStrategy(settings);
// }
private void setupCurrentFillMethod() { private void setupCurrentFillMethod() {
switch (selectedFillMethod) { switch (selectedFillMethod) {
case CUSTOM -> { case CUSTOM -> manualDataSettingsWindow.showModal();
customDataSettingsWindow.showModal();
}
case FILE -> case FILE -> fileDataSettingsWindow.showModal();
// TODO
MessageWindow.showModal(gui, "Не реализовано.");
case RANDOM -> case RANDOM ->
MessageWindow.showModal( MessageWindow.showModal(
@@ -106,6 +87,7 @@ public class CreateCollectionMenu extends BaseModalWindow {
gui, gui,
fillMethod -> { fillMethod -> {
selectedFillMethod = fillMethod; selectedFillMethod = fillMethod;
fillMethodLabel.setText( fillMethodLabel.setText(
"Способ заполнения: " + getFillMethodName(selectedFillMethod)); "Способ заполнения: " + getFillMethodName(selectedFillMethod));
}); });
@@ -113,57 +95,22 @@ public class CreateCollectionMenu extends BaseModalWindow {
menu.showModal(); menu.showModal();
} }
private void updateMainCollection(AppState state) { private void updateMainCollection() {
if (collectionSize <= 0) { if (fillStrategy == null) {
MessageWindow.showModal(gui, "Сначала задайте размер коллекции."); MessageWindow.showModal(gui, "Сначала настройте способ заполнения.");
return; return;
} }
switch (selectedFillMethod) { state.setMainCollection(fillStrategy.create());
case CUSTOM:
createCollectionFromCustomData(state);
break;
case RANDOM:
createCollectionFromRandomData(state);
break;
case FILE:
createCollectionFromFileData(state);
break;
}
}
private void createCollectionFromCustomData(AppState state) {
MyList<Student> customDataCollection = state.getCustomDataCollection();
MyList<Student> mainCollection = new MyLinkedList<>();
for (int i = 0; i < customDataCollection.size(); i++) {
mainCollection.add(customDataCollection.get(i));
}
state.setMainCollection(mainCollection);
MessageWindow.showModal(gui, "Коллекция успешно создана."); MessageWindow.showModal(gui, "Коллекция успешно создана.");
} }
private void createCollectionFromRandomData(AppState state) {
// TODO
MessageWindow.showModal(gui, "Не реализовано.");
}
private void createCollectionFromFileData(AppState state) {
// TODO
MessageWindow.showModal(gui, "Не реализовано.");
}
private String getFillMethodName(FillMethod fillMethod) { private String getFillMethodName(FillMethod fillMethod) {
return switch (fillMethod) { return switch (fillMethod) {
case CUSTOM -> "Пользовательские данные"; case CUSTOM -> "Пользовательские данные";
case RANDOM -> "Случайные данные"; case RANDOM -> "Случайные данные";
case FILE -> "Данные из файла"; case FILE -> "Данные из файла";
}; };
} }
@@ -0,0 +1,9 @@
package ru.project.ui.creation;
import ru.project.collection.MyList;
import ru.project.student.Student;
public interface FillStrategy {
MyList<Student> create();
}
@@ -5,28 +5,28 @@ import com.googlecode.lanterna.gui2.Label;
import com.googlecode.lanterna.gui2.LinearLayout; import com.googlecode.lanterna.gui2.LinearLayout;
import com.googlecode.lanterna.gui2.Panel; import com.googlecode.lanterna.gui2.Panel;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI; import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import java.util.function.Supplier; import java.util.function.Consumer;
import ru.project.collection.MyLinkedList; import ru.project.collection.MyLinkedList;
import ru.project.collection.MyList; import ru.project.collection.MyList;
import ru.project.model.AppState;
import ru.project.student.Student; import ru.project.student.Student;
import ru.project.student.StudentBuilder; import ru.project.student.StudentBuilder;
import ru.project.ui.base.BaseModalWindow; import ru.project.ui.base.BaseModalWindow;
import ru.project.ui.common.CollectionDisplayWindow; import ru.project.ui.common.CollectionDisplayWindow;
import ru.project.ui.common.CollectionSizeInputWindow;
import ru.project.ui.common.InputValueWindow; import ru.project.ui.common.InputValueWindow;
import ru.project.ui.common.MessageWindow; import ru.project.ui.common.MessageWindow;
public class CustomDataSettingsWindow extends BaseModalWindow { public class ManualDataSettingsWindow extends BaseModalWindow {
private final AppState state;
private final Supplier<Integer> requestedCollectionSize;
private final StudentBuilder studentBuilder; private final StudentBuilder studentBuilder;
private String groupNumber; private Integer lastRequestedCollectionSize;
private Double averageGrade; private String lastRequestedGroupNumber;
private Integer recordBookNumber; private Double lastRequestedAverageGrade;
private Integer selectedObjectIndex; private Integer lastRequestedRecordBookNumber;
private Integer lastRequestedSelectedObjectIndex;
private final Label sizeLabel;
private final Label groupNumberLabel; private final Label groupNumberLabel;
private final Label averageGradeLabel; private final Label averageGradeLabel;
private final Label recordBookNumberLabel; private final Label recordBookNumberLabel;
@@ -34,19 +34,23 @@ public class CustomDataSettingsWindow extends BaseModalWindow {
private MyList<Student> preparedCustomDataCollection; private MyList<Student> preparedCustomDataCollection;
public CustomDataSettingsWindow( private final ManualFillSettings settings;
WindowBasedTextGUI gui, AppState state, Supplier<Integer> collectionSize) { private final Consumer<ManualFillSettings> onApply;
public ManualDataSettingsWindow(WindowBasedTextGUI gui, Consumer<ManualFillSettings> onApply) {
super("Настройка пользовательских данных", gui); super("Настройка пользовательских данных", gui);
this.state = state; this.onApply = onApply;
this.requestedCollectionSize = collectionSize;
this.settings = new ManualFillSettings();
this.studentBuilder = new StudentBuilder(); this.studentBuilder = new StudentBuilder();
Panel panel = new Panel(); Panel panel = new Panel();
panel.setLayoutManager(new LinearLayout()); panel.setLayoutManager(new LinearLayout());
sizeLabel = new Label("Размер: не задан");
groupNumberLabel = new Label("Номер группы: не задан"); groupNumberLabel = new Label("Номер группы: не задан");
averageGradeLabel = new Label("Средний балл: не задан"); averageGradeLabel = new Label("Средний балл: не задан");
@@ -55,11 +59,14 @@ public class CustomDataSettingsWindow extends BaseModalWindow {
indexLabel = new Label("Индекс объекта: не задан"); indexLabel = new Label("Индекс объекта: не задан");
panel.addComponent(sizeLabel);
panel.addComponent(groupNumberLabel); panel.addComponent(groupNumberLabel);
panel.addComponent(averageGradeLabel); panel.addComponent(averageGradeLabel);
panel.addComponent(recordBookNumberLabel); panel.addComponent(recordBookNumberLabel);
panel.addComponent(indexLabel); panel.addComponent(indexLabel);
panel.addComponent(new Button("Задать размер", this::showCollectionSizeInputWindow));
panel.addComponent(new Button("Задать номер группы", this::setGroupNumber)); panel.addComponent(new Button("Задать номер группы", this::setGroupNumber));
panel.addComponent(new Button("Задать средний балл", this::setAverageGrade)); panel.addComponent(new Button("Задать средний балл", this::setAverageGrade));
@@ -79,25 +86,65 @@ public class CustomDataSettingsWindow extends BaseModalWindow {
setComponent(panel); setComponent(panel);
} }
private void showCollectionSizeInputWindow() {
CollectionSizeInputWindow window =
new CollectionSizeInputWindow(
gui, preparedCustomDataCollection.size(), this::handleCollectionSizeEntered);
window.showModal();
}
private void handleCollectionSizeEntered(int size) {
MyList<Student> resizedCollection = new MyLinkedList<>();
int currentCollectionSize = preparedCustomDataCollection.size();
int elementsToCopy = Math.min(currentCollectionSize, size);
for (int i = 0; i < elementsToCopy; i++) {
resizedCollection.add(preparedCustomDataCollection.get(i));
}
for (int i = elementsToCopy; i < size; i++) {
resizedCollection.add(null);
}
preparedCustomDataCollection = resizedCollection;
lastRequestedCollectionSize = size;
if (lastRequestedSelectedObjectIndex != null
&& lastRequestedSelectedObjectIndex >= lastRequestedCollectionSize) {
lastRequestedSelectedObjectIndex = null;
indexLabel.setText("Индекс объекта: не задан");
}
sizeLabel.setText("Размер: " + lastRequestedCollectionSize);
}
@Override @Override
public void showModal() { public void showModal() {
prepareCustomDataCollection(); prepareCustomDataCollection();
super.showModal(); super.showModal();
} }
private void prepareCustomDataCollection() { private void prepareCustomDataCollection() {
MyList<Student> currentCustomDataCollection = settings.getCollection();
preparedCustomDataCollection = new MyLinkedList<>(); preparedCustomDataCollection = new MyLinkedList<>();
int targetCollectionSize = requestedCollectionSize.get(); int currentCollectionSize = currentCustomDataCollection.size();
int currentCustomDataCollectionSize = state.getCustomDataCollection().size();
int elementsToCopy = Math.min(currentCustomDataCollectionSize, targetCollectionSize); int targetSize =
lastRequestedCollectionSize == null ? currentCollectionSize : lastRequestedCollectionSize;
int elementsToCopy = Math.min(currentCollectionSize, targetSize);
for (int i = 0; i < elementsToCopy; i++) { for (int i = 0; i < elementsToCopy; i++) {
preparedCustomDataCollection.add(state.getCustomDataCollection().get(i)); preparedCustomDataCollection.add(currentCustomDataCollection.get(i));
} }
for (int i = elementsToCopy; i < targetCollectionSize; i++) { for (int i = elementsToCopy; i < targetSize; i++) {
preparedCustomDataCollection.add(null); preparedCustomDataCollection.add(null);
} }
} }
@@ -108,17 +155,17 @@ public class CustomDataSettingsWindow extends BaseModalWindow {
gui, gui,
"Номер группы", "Номер группы",
"Введите номер группы (например, A12):", "Введите номер группы (например, A12):",
groupNumber, lastRequestedGroupNumber,
value -> { value -> {
if (!value.matches(Student.getGroupNumberPattern())) { if (!value.matches(Student.getGroupNumberPattern())) {
MessageWindow.showModal(gui, "Номер группы должен соответствовать формату A12."); MessageWindow.showModal(gui, "Номер группы должен соответствовать формату A12.");
return false; return false;
} }
groupNumber = value; lastRequestedGroupNumber = value;
studentBuilder.setGroupNumber(value); studentBuilder.setGroupNumber(value);
groupNumberLabel.setText("Номер группы: " + groupNumber); groupNumberLabel.setText("Номер группы: " + lastRequestedGroupNumber);
return true; return true;
}); });
@@ -132,7 +179,7 @@ public class CustomDataSettingsWindow extends BaseModalWindow {
gui, gui,
"Средний балл", "Средний балл",
"Введите средний балл от 0.0 до 5.0:", "Введите средний балл от 0.0 до 5.0:",
averageGrade == null ? null : String.valueOf(averageGrade), lastRequestedAverageGrade == null ? null : String.valueOf(lastRequestedAverageGrade),
value -> { value -> {
try { try {
double parsedValue = Double.parseDouble(value); double parsedValue = Double.parseDouble(value);
@@ -145,11 +192,11 @@ public class CustomDataSettingsWindow extends BaseModalWindow {
return false; return false;
} }
averageGrade = parsedValue; lastRequestedAverageGrade = parsedValue;
studentBuilder.setAverageGrade(parsedValue); studentBuilder.setAverageGrade(parsedValue);
averageGradeLabel.setText("Средний балл: " + averageGrade); averageGradeLabel.setText("Средний балл: " + lastRequestedAverageGrade);
return true; return true;
@@ -169,7 +216,9 @@ public class CustomDataSettingsWindow extends BaseModalWindow {
gui, gui,
"Номер зачётной книжки", "Номер зачётной книжки",
"Введите номер зачётной книжки:", "Введите номер зачётной книжки:",
recordBookNumber == null ? null : String.valueOf(recordBookNumber), lastRequestedRecordBookNumber == null
? null
: String.valueOf(lastRequestedRecordBookNumber),
value -> { value -> {
try { try {
int parsedValue = Integer.parseInt(value); int parsedValue = Integer.parseInt(value);
@@ -181,11 +230,12 @@ public class CustomDataSettingsWindow extends BaseModalWindow {
return false; return false;
} }
recordBookNumber = parsedValue; lastRequestedRecordBookNumber = parsedValue;
studentBuilder.setRecordBookNumber(parsedValue); studentBuilder.setRecordBookNumber(parsedValue);
recordBookNumberLabel.setText("Номер зачётной книжки: " + recordBookNumber); recordBookNumberLabel.setText(
"Номер зачётной книжки: " + lastRequestedRecordBookNumber);
return true; return true;
@@ -205,34 +255,31 @@ public class CustomDataSettingsWindow extends BaseModalWindow {
gui, gui,
"Индекс объекта", "Индекс объекта",
"Введите индекс объекта:", "Введите индекс объекта:",
selectedObjectIndex == null ? null : String.valueOf(selectedObjectIndex), lastRequestedSelectedObjectIndex == null
? null
: String.valueOf(lastRequestedSelectedObjectIndex),
value -> { value -> {
try { try {
int index = Integer.parseInt(value); int index = Integer.parseInt(value);
if (index < 0) { if (index < 0) {
MessageWindow.showModal(gui, "Индекс объекта не может быть отрицательным."); MessageWindow.showModal(gui, "Индекс объекта не может быть отрицательным.");
return false; return false;
} }
int size = requestedCollectionSize.get(); if (index >= preparedCustomDataCollection.size()) {
if (index >= size) {
MessageWindow.showModal(gui, "Индекс должен быть меньше размера коллекции."); MessageWindow.showModal(gui, "Индекс должен быть меньше размера коллекции.");
return false; return false;
} }
selectedObjectIndex = index; lastRequestedSelectedObjectIndex = index;
indexLabel.setText("Индекс объекта: " + selectedObjectIndex); indexLabel.setText("Индекс объекта: " + lastRequestedSelectedObjectIndex);
return true; return true;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
MessageWindow.showModal(gui, "Введите целое число."); MessageWindow.showModal(gui, "Введите целое число.");
return false; return false;
} }
}); });
@@ -246,28 +293,28 @@ public class CustomDataSettingsWindow extends BaseModalWindow {
return; return;
} }
if (selectedObjectIndex == null) { if (lastRequestedSelectedObjectIndex == null) {
MessageWindow.showModal(gui, "Сначала задайте индекс объекта."); MessageWindow.showModal(gui, "Сначала задайте индекс объекта.");
return; return;
} }
if (selectedObjectIndex >= preparedCustomDataCollection.size()) { if (lastRequestedSelectedObjectIndex >= preparedCustomDataCollection.size()) {
MessageWindow.showModal(gui, "Индекс объекта выходит за границы подготовленной коллекции."); MessageWindow.showModal(gui, "Индекс объекта выходит за границы подготовленной коллекции.");
return; return;
} }
Student student = studentBuilder.build(); Student student = studentBuilder.build();
preparedCustomDataCollection.set(selectedObjectIndex, student); preparedCustomDataCollection.set(lastRequestedSelectedObjectIndex, student);
MessageWindow.showModal(gui, "Данные объекта успешно заданы."); MessageWindow.showModal(gui, "Данные объекта успешно заданы.");
} }
private void apply() { private void apply() {
state.setCustomDataCollection(preparedCustomDataCollection); settings.setCollection(preparedCustomDataCollection);
prepareCustomDataCollection(); onApply.accept(settings);
MessageWindow.showModal(gui, "Пользовательские данные успешно применены."); MessageWindow.showModal(gui, "Настройки создания коллекции вручную успешно применены.");
} }
private void preview() { private void preview() {
@@ -284,6 +331,8 @@ public class CustomDataSettingsWindow extends BaseModalWindow {
} }
private boolean hasStudentData() { private boolean hasStudentData() {
return groupNumber != null && averageGrade != null && recordBookNumber != null; return lastRequestedGroupNumber != null
&& lastRequestedAverageGrade != null
&& lastRequestedRecordBookNumber != null;
} }
} }
@@ -0,0 +1,22 @@
package ru.project.ui.creation.manual;
import ru.project.collection.MyLinkedList;
import ru.project.collection.MyList;
import ru.project.student.Student;
public class ManualFillSettings {
private MyList<Student> manualDataCollection;
public ManualFillSettings() {
this.manualDataCollection = new MyLinkedList<>();
}
public MyList<Student> getCollection() {
return manualDataCollection;
}
public void setCollection(MyList<Student> collection) {
this.manualDataCollection = collection;
}
}
@@ -0,0 +1,28 @@
package ru.project.ui.creation.manual;
import ru.project.collection.MyLinkedList;
import ru.project.collection.MyList;
import ru.project.student.Student;
import ru.project.ui.creation.FillStrategy;
public class ManualFillStrategy implements FillStrategy {
private final ManualFillSettings settings;
public ManualFillStrategy(ManualFillSettings settings) {
this.settings = settings;
}
@Override
public MyList<Student> create() {
MyList<Student> mainCollection = new MyLinkedList<>();
MyList<Student> manualDataCollection = settings.getCollection();
for (int i = 0; i < manualDataCollection.size(); i++) {
mainCollection.add(manualDataCollection.get(i));
}
return mainCollection;
}
}