public class Task { @Getter @Setter private Long id; @Getter @Setter private TaskStatus taskStatus; @Getter @Setter private String name; @Getter @Setter private LocalDate dueDate; @Getter @Setter private int postponeCount; public static final int POSTPONE_MAX_COUNT = 3; } public class Task { @Getter private Long id; @Getter private final String name; @Getter private LocalDate dueDate; private TaskStatus taskStatus; private int postponeCount; public static final int POSTPONE_MAX_COUNT = 3; public Task(String name, LocalDate dueDate) { if (name == null || dueDate == null) { throw new IllegalArgumentException("必須項目が設定されていません"); } this.name = name; this.dueDate = dueDate; this.taskStatus = TaskStatus.UNDONE; this.postponeCount = 0; } public void postpone() { if (postponeCount >= POSTPONE_MAX_COUNT) { throw new IllegalArgumentException("最大延期回数を超過しています"); } dueDate = dueDate.plusDays(1L); postponeCount++; } public void done() { this.taskStatus = TaskStatus.DONE; } public boolean isUndone() { return this.taskStatus == TaskStatus.UNDONE; } public boolean canPostpone() { return this.postponeCount < POSTPONE_MAX_COUNT; } } public interface Task { Long getId(); String getName(); }