Task Tracker CLI
-
Task This class defines the structure of a task. It includes the Id, description, status, when it was created and when it was last updated. There are two constructors, one that accespts all fields and anpther one that only requires description and the other fields are initialized with default values. There are methods like getters, setters, toString, toJSON, fromJSON. The method toJSON converts the task into a JSON format. while the method fromJSON does the revers.
-
TaskStorage This class handles the interaction with the file system, specifically with the tasks.json file that stores all tasks. The createFile() method checks if the JSON file already exists. If does not, it creats a new file and initializes it with empty JSON array ([]). The loadTasks() method reads the content of the file, parse it and converts each JSON object into a Task instance using the fromJSON() method defined in Task class. The saveTasks() method takes a list of tasks and writes them back to the JSON file. It serializes each task into JSON using the toJSON() method.
-
TaskTracker This is the main class, and it implements a CLI that allows the user to manage tasks using the terminal commands. When the program starts, it checks whether the task storage file exists. It then reads the current list of tasks. The first command-line argument determines the action to perform (e.g. add, delete). The class uses a switch case to handle each type of command. Each handler method process the input arguments, performs the required operation and prints a message to the console. After every command is executed, the updated task is saved back to the file. This ensures persistence. This class also handles edge cases such as missing or invalid arguments, invalid task IDs etc. So, this coordinates the entire flow of the task management application.