Добавлено перечисление TaskStatus для управления статусами задач и улучшения читаемости кода.

This commit is contained in:
KamaSK 2025-05-20 12:26:48 +03:00
parent 5652c8246b
commit 1932cdb297
3 changed files with 47 additions and 2 deletions

View File

@ -9,7 +9,7 @@ class Task {
private int id;
private String title;
private String description;
private boolean completed = false;
private boolean completed;
private LocalDate createdAt;
static {

View File

@ -0,0 +1,41 @@
package ru.kamask.pet;
public enum TaskStatus {
NEW("Новое") {
@Override
String getColorCode() {
return "\u001B[32m";
}
},
IN_PROGRESS("В работе") {
@Override
String getColorCode() {
return "\u001B[35m";
}
},
COMPLETED("Сделано") {
@Override
String getColorCode() {
return "\u001B[34m";
}
},
CANCELLED("Отменено") {
@Override
String getColorCode() {
return "\u001B[31m";
}
};
abstract String getColorCode();
private final String description;
TaskStatus(String description) {
this.description = description;
}
String getDescription() {
return description;
}
}

View File

@ -14,7 +14,11 @@ public class TodoApp {
TodoApp app = new TodoApp();
taskManager = app.new TaskManager();
app.run();
TaskStatus status = TaskStatus.valueOf("NEW");
System.out.println(status.getDescription());
// app.run();
}