1 Commits
Author SHA1 Message Date
KamaSK 0f8f4037c9 Merge pull request 'dev' (#43) from dev into main
Reviewed-on: #43
2025-06-04 15:14:11 +03:00
4 changed files with 11 additions and 20 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>ru.kamask.pet</groupId>
<artifactId>todo</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.1</version>
<properties>
<maven.compiler.release>24</maven.compiler.release>
@@ -30,17 +30,18 @@ public class ListCommand implements Command {
String formatWithTable(List<Task> tasks, String msgIfEmpty){
String template = "%-2s | %-30s | %s\n";
var res = new StringBuilder(String.format(template, "ID", "Название задачи", "Статус"));
res.append("-".repeat(50) + "\n");
String res = "";
res += String.format(template, "ID", "Название задачи", "Статус");
res += "-".repeat(50) + "\n";
if (tasks.size() == 0)
return res.append("\n" + msgIfEmpty).toString();
return res + "\n" + msgIfEmpty;
for (Task task : tasks) {
SimpleTask.Data data = ((SimpleTask) task).data();
res.append(String.format(template, data.id(), data.title(), data.done() ? "выполнено" : "не выполнено"));
res += String.format(template, data.id(), data.title(), data.done() ? "выполнено" : "не выполнено");
}
return res.toString();
return res;
}
}
@@ -1,5 +0,0 @@
package ru.kamask.pet.todo.model;
public interface Identifiable {
int getId();
}
@@ -1,6 +1,6 @@
package ru.kamask.pet.todo.model;
public abstract class Task implements Identifiable{
public abstract class Task {
private static int nextId = 1;
protected int id;
@@ -11,13 +11,8 @@ public abstract class Task implements Identifiable{
this.title = title;
}
@Override
public int getId() {
return id;
}
public int id() {
return getId();
return id;
}
@Override