Merge pull request 'добавление интерфейса Identifiable и его реализация в Task (closes #45)' (#54) from feature/add-identifiable into dev

Reviewed-on: #54
This commit is contained in:
KamaSK 2025-06-06 18:15:53 +03:00
commit 2c7deaa9ae
2 changed files with 12 additions and 2 deletions

View File

@ -0,0 +1,5 @@
package ru.kamask.pet.todo.model;
public interface Identifiable {
int getId();
}

View File

@ -1,6 +1,6 @@
package ru.kamask.pet.todo.model;
public abstract class Task {
public abstract class Task implements Identifiable{
private static int nextId = 1;
protected int id;
@ -11,10 +11,15 @@ public abstract class Task {
this.title = title;
}
public int id() {
@Override
public int getId() {
return id;
}
public int id() {
return getId();
}
@Override
public String toString() {
return String.format("Задача: id - %d, title: \"%s\"", id, title);