74 lines
1.7 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package ru.kamask.pet;
import java.time.LocalDate;
class Task {
private static int nextId;
static int taskCount;
static {
taskCount = 0;
nextId = 0;
}
private int id;
private String title;
private String description;
private boolean completed = false;
private LocalDate createdAt;
Task(String title, String description) {
this.title = title;
this.description = description;
};
{
id = ++nextId;
createdAt = LocalDate.now();
++taskCount;
}
static void printTotalTasksCreated() {
System.out.println("Колличество дел: " + taskCount);
}
void printInfo() {
String stringCompleted = completed ? "[х]" : "[ ]";
System.out.printf("%-3d | %-20s | %s\n", id, title, stringCompleted);
}
void printInfo(boolean full) {
if (!full) {
printInfo();
return;
}
String template = """
──────────────────────────────
Номер: %-3d
Дата создания: %s
Статус: %s
Название: %-20s
------------------------------
%s
""";
;
String stringCompleted = completed ? "выполнено" : "не выполнено";
System.out.printf(template, id, createdAt, stringCompleted, title, description);
}
void toggleCompleted() {
completed = !completed;
}
int getId() {
return id;
}
boolean getCompleted() {
return completed;
}
}