Skip to content

Commit

Permalink
Менеджер задач - исправлены все замечания первого ревью
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaPegushina committed Oct 29, 2024
1 parent 137a23b commit 948eeab
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 123 deletions.
38 changes: 11 additions & 27 deletions src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ public static void main(String[] args) {
System.out.println("Создаем задачи:\n");

Task task1 = new Task("Просто задача - 1", "Описание простой задачи - 1");
manager.addNewTask(task1);
int task1Id = manager.addNewTask(task1);
Task task2 = new Task("Просто Задача - 2", "Описание простой задачи - 2");
manager.addNewTask(task2);
int task2Id = manager.addNewTask(task2);

Epic epic1 = new Epic("Эпическая задача - 1",
"Описание эпической задачи - 1");
manager.addNewEpic(epic1);
int epic1Id = manager.addNewEpic(epic1);
Epic epic2 = new Epic("Эпическая задача - 2",
"Описание эпической задачи - 2");
manager.addNewEpic(epic2);
int epic2Id = manager.addNewEpic(epic2);

Subtask subtask1 = new Subtask( "Подзадача - 1",
"Описание подзадачи - 1, эпической задачи - 1", epic1.getId());
manager.addNewSubtask(subtask1);
int subtask1Id = manager.addNewSubtask(subtask1);
Subtask subtask2 = new Subtask("Подзадача - 2",
"Описание подзадачи - 2, эпической задачи - 1", epic1.getId());
manager.addNewSubtask(subtask2);
int subtask2Id = manager.addNewSubtask(subtask2);
Subtask subtask3 = new Subtask( "Подзадача - 3",
"Описание подзадачи - 3, эпической задачи - 2", epic2.getId());
manager.addNewSubtask(subtask3);
int subtask3Id = manager.addNewSubtask(subtask3);

System.out.println(manager.getAllTasks().toString());
System.out.println(manager.getAllEpics().toString());
Expand All @@ -48,7 +48,7 @@ public static void main(String[] args) {
System.out.println(manager.getAllSubtasks().toString());
System.out.println(manager.getAllEpics().toString());

Epic epic3 = new Epic(epic1.getId(), "Эпическая задача - 3", "Ставим вместо эпической задачи - 1", epic1.getStatus(), epic1.getListOfSubtaskId());
Epic epic3 = new Epic(epic1.getId(), "Эпическая задача - 3", "Ставим вместо эпической задачи - 1", epic1.getStatus());
manager.updateEpic(epic3);

System.out.println(manager.getAllEpics().toString());
Expand Down Expand Up @@ -84,26 +84,10 @@ public static void main(String[] args) {
System.out.println("Удаляем подзадачу - 3, эпической задачи - 2");
manager.deleteSubtask(subtask3.getId());
System.out.println(manager.getAllSubtasks().toString() + '\n');
System.out.println("Удаляем эпическую задачу - 1");
manager.deleteEpic(epic1.getId());
System.out.println(manager.getAllEpics().toString());
System.out.println(manager.getAllSubtasks().toString() + '\n');

/*
System.out.println("Удаляем все эпические задачи вместе с подзадачами");
manager.deleteAllEpics();
System.out.println(manager.getAllEpics().toString());
System.out.println("Удаляем все подзадачи и очищаем списки эпиков");
manager.deleteAllSubtasks();
System.out.println(manager.getAllSubtasks().toString());
//System.out.println("Удаляем все простые задачи");
manager.deleteAllTasks();*/

//System.out.println(manager.getAllTasks().toString());

//System.out.println("Удаляем все подзадачи и очищаем эпики");
//manager.deleteAllSubtasks();
//System.out.println(manager.getAllSubtasks().toString());
//System.out.println(manager.getAllEpics().toString());
System.out.println(manager.getAllEpics().toString());
}
}
13 changes: 6 additions & 7 deletions src/model/Epic.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

public class Epic extends Task {

private ArrayList<Integer> listOfSubtaskId = new ArrayList<>();
private final ArrayList<Integer> subtaskIds = new ArrayList<>();

public Epic(int id, String title, String description, Status status, ArrayList<Integer> listOfSubtaskId) {
public Epic(int id, String title, String description, Status status) {
super(id, title, description, status);
this.listOfSubtaskId = listOfSubtaskId;
}

public Epic(String title, String description) {
Expand All @@ -17,17 +16,17 @@ public Epic(String title, String description) {
}

public void addSubtaskId(int subtaskId) {
this.listOfSubtaskId.add(subtaskId);
this.subtaskIds.add(subtaskId);
}

public ArrayList<Integer> getListOfSubtaskId() {
return listOfSubtaskId;
public ArrayList<Integer> getSubtaskIds() {
return subtaskIds;
}

@Override
public String toString() {
return "\nEpic{" +
"listOfSubtaskId=" + listOfSubtaskId +
"subtaskIds=" + subtaskIds +
", id=" + id +
", title='" + title + '\'' +
", description='" + description + '\'' +
Expand Down
6 changes: 1 addition & 5 deletions src/model/Subtask.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package model;

public class Subtask extends Task {
private int epicId;
private final int epicId;

public Subtask(int id, String title, String description, Status status, int epicId) {
super(id, title, description, status);
Expand All @@ -17,10 +17,6 @@ public int getEpicId() {
return epicId;
}

public void setEpicId(int epicId) {
this.epicId = epicId;
}

@Override
public String toString() {
return "\nSubtask{" +
Expand Down
25 changes: 0 additions & 25 deletions src/service/Repository.java

This file was deleted.

Loading

0 comments on commit 948eeab

Please sign in to comment.