Skip to content

Sprint 8 solution time and duration#6

Open
n20va wants to merge 11 commits intomainfrom
sprint_8-solution-time-and-duration
Open

Sprint 8 solution time and duration#6
n20va wants to merge 11 commits intomainfrom
sprint_8-solution-time-and-duration

Conversation

@n20va
Copy link
Copy Markdown
Owner

@n20va n20va commented Jul 10, 2025

No description provided.

Comment thread src/model/Epic.java
import java.util.List;
import java.util.Objects;

public class Epic extends Task {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

для эпика нужно ввести атрибут endTime
+
добавить для него сеттер и переопределить родительский getEndTime(), сделав из него обычный геттер

Comment thread src/model/Epic.java
public void removeSubtaskId(int id) {
subtaskIds.remove(Integer.valueOf(id));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а какой в таком переопределении родительских методов? В таком виде они итак доступны))

Comment thread src/manager/InMemoryTaskManager.java Outdated
protected final Set<Task> prioritizedTasks = new TreeSet<>(Comparator
.comparing(Task::getStartTime, Comparator.nullsLast(LocalDateTime::compareTo))
.thenComparingInt(Task::getId));
protected final List<Task> history = new ArrayList<>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

откуда это переменная вдруг взялась???? верни всю работу с историей как она была сделана раньше, этот функционал больше меняться не будет

Comment thread src/manager/InMemoryTaskManager.java Outdated
}

@Override
public void updateEpic(Epic epic) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

метод обновления эпика тоже верни как был раньше

for (int subId : epic.getSubtaskIds()) {
Subtask subtask = subtasks.remove(subId);
if (subtask != null) {
prioritizedTasks.remove(subtask);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

еще подзадачу из истории нужно удалить

Comment thread src/manager/InMemoryTaskManager.java Outdated
historyManager.remove(subtaskId);

for (Subtask subtask : subtasks.values()) {
prioritizedTasks.remove(subtask);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и здесь тоже


if (subtasksOfEpic.isEmpty()) {
epic.setDuration(Duration.ZERO);
epic.setStartTime(null);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

здесь еще нужно будет в endTime передать null

}

epic.setDuration(totalDuration);
epic.setStartTime(earliestStart);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

соответственно здесь тоже посчитанный latestEnd нужно будет отдать в endTime

epic.setDuration(totalDuration);
epic.setStartTime(earliestStart);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

эти два последних метода удалить

protected int generateId() {
return idCounter++;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

методы создания сущностей потеряли свои доработки по работе с файлами (их нужно вернуть)
+
нужно вернуть метод, проверяющий пересечение задач/подзадач, он целиком куда-то пропал. Я не буду писать к каждому методу про вернуть использование checkTimeIntersection(), чтобы не перегружать ревью

Comment thread src/manager/InMemoryTaskManager.java Outdated
if (epic == null || !epics.containsKey(epic.getId())) return;
epics.put(epic.getId(), epic);
updateEpicTimeAndDuration(epic);
if (epics.containsKey(epic.getId())) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

такая реализация метод обновления эпика оставляет возможность сломать связь эпика со своими подзадачами или даже указать в качестве подзадачи любую сущность, в том числе не существующую. Потому что наполнение хранилища subtaskIds в новом эпике принимается "на веру". Поэтому посмотри какая реализация метода была принята в самом начале. Менять ее смысла нет, потому что при любых изменениях реализации метода, что старая, что новая версии метода, должны выдавать один и тот же результат, а именно изменить в эпике всего два поля



@Override
public void updateSubtask(Subtask subtask) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

этот метод в прошлый раз был сделан правильно, единственное , что по нему нужно было сделать, так это заменить использование методов updateEpicStatus() и updateEpicTimeAndDuration() на updateEpicFields() раз уж ты их объединила

Comment thread src/manager/InMemoryTaskManager.java Outdated
if (subtask != null) historyManager.add(subtask);
return subtask;
public void addTask(Task task) {
task.setId(generateId());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

сделай сначала проверку пересечения, потом присваивай сущности id

Comment thread src/manager/InMemoryTaskManager.java Outdated
if (!epics.containsKey(subtask.getEpicId())) {
throw new IllegalArgumentException("Epic not found");
}
subtask.setId(generateId());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

аналогично

subtasks.put(subtask.getId(), subtask);
prioritizedTasks.add(subtask);
updateEpicFields(epics.get(subtask.getEpicId()));
if (!subtasks.containsKey(subtask.getId())) return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

еще осталось вернуть проверку равенства epicId в старой и новой версии подзадачи

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants