Compare commits
2 Commits
45c6e6e3d4
...
0183648b3c
| Author | SHA1 | Date | |
|---|---|---|---|
| 0183648b3c | |||
| a4b250f10b |
@ -1,6 +1,6 @@
|
|||||||
package ru.kamask.pet;
|
package ru.kamask.pet;
|
||||||
|
|
||||||
public class Task {
|
class Task {
|
||||||
private int id;
|
private int id;
|
||||||
private String title;
|
private String title;
|
||||||
private String description;
|
private String description;
|
||||||
@ -12,12 +12,12 @@ public class Task {
|
|||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printInfo() {
|
void printInfo() {
|
||||||
String stringCompleted = completed ? "[х]" : "[ ]";
|
String stringCompleted = completed ? "[х]" : "[ ]";
|
||||||
System.out.printf("%-3d | %-20s | %s\n", id, title, stringCompleted);
|
System.out.printf("%-3d | %-20s | %s\n", id, title, stringCompleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printInfo(boolean full) {
|
void printInfo(boolean full) {
|
||||||
if (!full) {
|
if (!full) {
|
||||||
printInfo();
|
printInfo();
|
||||||
return;
|
return;
|
||||||
@ -38,15 +38,15 @@ public class Task {
|
|||||||
System.out.printf(template, id, stringCompleted, title, description);
|
System.out.printf(template, id, stringCompleted, title, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleCompleted() {
|
void toggleCompleted() {
|
||||||
completed = !completed;
|
completed = !completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getCompleted() {
|
boolean getCompleted() {
|
||||||
return completed;
|
return completed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ public class TodoApp {
|
|||||||
displayMainMenu();
|
displayMainMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int requestIntFromInput(String template, int[] allowedInts) {
|
private static int requestIntFromInput(String template, int[] allowedInts) {
|
||||||
do {
|
do {
|
||||||
System.out.print(template);
|
System.out.print(template);
|
||||||
int input;
|
int input;
|
||||||
@ -35,7 +35,7 @@ public class TodoApp {
|
|||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void displayMainMenu() {
|
private static void displayMainMenu() {
|
||||||
while (true) {
|
while (true) {
|
||||||
String menu = """
|
String menu = """
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ public class TodoApp {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task getTaskById(int id) {
|
private static Task getTaskById(int id) {
|
||||||
for (int i = 0; i < tasksCounter; i++) {
|
for (int i = 0; i < tasksCounter; i++) {
|
||||||
if (tasks[i].getId() == id)
|
if (tasks[i].getId() == id)
|
||||||
return tasks[i];
|
return tasks[i];
|
||||||
@ -134,7 +134,7 @@ public class TodoApp {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void displayTask(Task task) {
|
private static void displayTask(Task task) {
|
||||||
task.printInfo(true);
|
task.printInfo(true);
|
||||||
String firstOption = task.getCompleted() ? "[1]Не выполнено" : "[1]Выполнено";
|
String firstOption = task.getCompleted() ? "[1]Не выполнено" : "[1]Выполнено";
|
||||||
int input = requestIntFromInput(firstOption + " [0]Главное меню\n\nВвод:",
|
int input = requestIntFromInput(firstOption + " [0]Главное меню\n\nВвод:",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user