This is part of the Java Developer course from Yandex. Module - standard Java library and its features.
The repository contains my solution that has been verified from the reviewer to the task described below.
How does a person usually shop? If he needs not one product, but several, then it is very likely that he will first make a list so as not to forget anything. You can do this anywhere: on a piece of paper, in a note-taking application, or, for example, in a message to yourself in a messenger.
And now imagine that this is not a list of products, but of full-fledged cases. And not some simple ones like " wash the dishes**"** or " call grandma**",** but complex ones — for example, " organize a big family holiday**"** or " buy an apartment**"**. Each of these tasks can be divided into several stages with its own nuances and deadlines. And if not one person, but a whole team will work on their implementation, then the organization of the process will become even more difficult.
Both version control systems help the team work with common code, and task trackers allow you to effectively organize joint work on tasks. You have to write a backend for such a tracker. As a result, you should get a program responsible for forming a data model for this page:
The user will not see the console of your application. Therefore, you need to make sure that the methods do not just print something to the console, but also return objects of the desired types.
You can add console output for self-checking in the Main
class, but it should not affect the operation of methods.
The simplest building block of such a system is the task (Eng. task). The task has the following properties:
-
Name, briefly describing the essence of the task (for example, "Moving").
-
** Description**, which reveals the details.
-
The unique identification number of the task by which it can be found.
-
Status showing her progress. We will highlight the following stages of the task's life:
-
NEW
— the task has just been created, but it has not yet been started. -
IN_PROGRESS
— the task is being worked on. -
`DONE' — the task is completed.
Sometimes, to perform some large-scale task, it is better to break it into ** subtasks ** (Eng. subtask). A large task, which is divided into subtasks, we will call ** epic ** (Eng. epic).
Thus, there can be three types of tasks in our system: regular tasks, epics and subtasks. The following conditions must be met for them:
- For each subtask, it is known within which epic it is performed.
- Every epic knows what subtasks it includes.
- The completion of all epic subtasks is considered the completion of the epic.
Each task type has an identifier. This is an integer that is unique for all types of tasks. We use it to find, update, and delete tasks. When creating a task, the manager assigns a new identifier to it.
In addition to classes for describing tasks, you need to implement a class for the manager object. It will be launched at the start of the program and manage all tasks. The following functions should be implemented in it:
-
The ability to store tasks of all types. To do this, you need to choose a suitable collection.
-
Methods for each of the task types (Task/Epic/Subtask):
-
Getting a list of all tasks.
-
Delete all tasks.
-
Getting by ID.
-
Creation. The object itself must be passed as a parameter.
-
Update. The new version of the object with the correct identifier is passed as a parameter.
-
Deletion by ID.
-
Additional methods:
-
Getting a list of all subtasks of a certain epic.
-
Statuses are managed according to the following rule:
-
The manager does not choose the status for the task himself. Information about it comes to the manager along with information about the task itself. According to this data, in some cases it will retain the status, in others it will count.
-
For epics:
- if the epic has no subtasks or all of them have the status
NEW
, then the status should be `NEW'. - if all subtasks have the status
DONE
, then the epic is considered completed — with the status `DONE'. - in all other cases, the status should be `IN_PROGRESS'.