Skip to content

Conversation

@Max-Browckin
Copy link
Owner

No description provided.

Copy link

@avfyodorov avfyodorov left a comment

Choose a reason for hiding this comment

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

Добрый день, Максим!

Практически всё сделано, единственное нужно будет немного поправить работу с отсортированным по времени списком.

public class Epic extends Task {
private ArrayList<Subtask> subtaskList = new ArrayList<>();
private Duration duration;
private LocalDateTime startTime;

Choose a reason for hiding this comment

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

  private Duration duration;
  private LocalDateTime startTime;

Эти два поля лишние, потому что они дублируют соответствующие поля в классе предке - Task.
Нужно использовать поля класса Task
Поля в Task лучше сделать protected, чтобы они были доступны напрямую.

@@ -0,0 +1,7 @@
package manager;

Choose a reason for hiding this comment

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

Собственные исключения принято хранить в отдельном пакете, например, exceptions

private int getNextID() {
return nextID++;
@Override
public List<Task> getPrioritizedTasks() {

Choose a reason for hiding this comment

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

К сожалению, данная реализация не соответствует требованиям ТЗ:

.=============
Предполагается, что пользователь будет часто запрашивать этот список, поэтому подберите подходящую структуру данных для хранения. Сложность получения должна быть уменьшена ... до O(n)
...
Если сортировать список заново каждый раз, сложность получения будет O(n*log(n)). Можно хранить все задачи заранее отсортированными с помощью класса TreeSet.
.===========
Метод получения списка отсортированных задач должен выглядеть так:

	@Override
	public List<Task> getPrioritizedTasks() {
		return new ArrayList<>(prioritizedTasks);
	}

Нужно будет завести переменную - отсортированный список и поддерживать её в актуальном состоянии.

protected final Set<Task> prioritizedTasks = new TreeSet<>(Comparator.comparing(Task::getStartTime));

Copy link

@avfyodorov avfyodorov left a comment

Choose a reason for hiding this comment

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

Добрый вечер, Максим!

Ещё несколько небольших уточнений.
И ставьте, пожалуйста, пометки, чтобы было понятно, что комментарии замечены. )

@Override
public void deleteTasks() {
tasks.clear();
prioritizedTasks.clear();

Choose a reason for hiding this comment

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

Не совсем так. Лучше как-то так -

@Override
	public void deleteTasks() {
		for (Task task : tasks.values()) {
			historyManager.remove(task.getId());
         		prioritizedTasks.remove(task);
		}
		tasks.clear();
	}

Copy link
Owner Author

Choose a reason for hiding this comment

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

Все комментарии замечены, все исправил
Надеюсь правильно

public void deleteEpics() {
epics.clear();
subtasks.clear();
prioritizedTasks.clear();

Choose a reason for hiding this comment

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

И здесь чистить из истории и из отсортированного списка, но ТОЛЬКО ПОДЗАДАЧИ.

@Override
public void deleteSubtasks() {
subtasks.clear();
prioritizedTasks.clear();

Choose a reason for hiding this comment

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

и здесь

tasks.remove(id);
Task task = tasks.remove(id);
if (task != null) {
prioritizedTasks.remove(task);

Choose a reason for hiding this comment

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

и из истории

subtasks.remove(subtask.getId());
Epic epic = epics.get(id);
if (epic != null) {
ArrayList<Subtask> epicSubtasks = epic.getSubtaskList();

Choose a reason for hiding this comment

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

и из истории

int epicID = subtask.getEpicID();
subtasks.remove(id);
prioritizedTasks.remove(subtask);
historyManager.remove(id);

Choose a reason for hiding this comment

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

а здесь уже есть :-)

Copy link

@avfyodorov avfyodorov left a comment

Choose a reason for hiding this comment

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

Добрый день, Максим!

Замечаний нет.
Работа принята.

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.

3 participants