A feature-rich command-line task manager built in Java that helps you organize and manage your tasks efficiently with priority levels, due dates, and persistent storage.
- ✅ Add Tasks with due dates and priority levels (LOW, MEDIUM, HIGH)
- ✅ List Tasks sorted automatically by priority and due date
- ✅ Mark Tasks as Done to track completion
- ✅ Delete Tasks with confirmation prompts
- ✅ Undo Deletion to restore accidentally deleted tasks
- ✅ Persistent Storage in
tasks.txtfile - ✅ Smart Sorting by priority (HIGH → MEDIUM → LOW) and due date
- ✅ User-Friendly CLI with input validation
- Java Development Kit (JDK) 11 or higher
- Command line / Terminal access
- Clone the repository
git clone https://github.com/yourusername/task-manager-cli.git
cd task-manager-cli- Compile the program
javac TaskManager.java TaskStorage.java Task.java- Run the program
java TaskManagertask-manager-cli/
├── TaskManager.java # Main program with CLI interface
├── Task.java # Task model with priority and date handling
├── TaskStorage.java # File I/O operations for persistence
├── tasks.txt # Auto-generated task storage file
└── README.md # Project documentation
==================
Task Manager
==================
1. Add Task
2. List Tasks
3. Mark Task as Done
4. Delete Task
5. Undo Last Deletion
6. Exit
Enter task description: Complete Java project
Enter due date (YYYY-MM-DD): 2024-12-31
Enter priority (LOW, MEDIUM, HIGH): HIGH
- Description: Any text describing your task
- Due Date: Format must be
YYYY-MM-DD - Priority: Choose from
LOW,MEDIUM, orHIGH
Displays all tasks sorted by:
- Priority (HIGH → MEDIUM → LOW)
- Due date (earliest first)
Example output:
1. [done] Complete Java project | Due: 2024-12-31 | Priority: HIGH
2. [ ] Study for exam | Due: 2024-12-15 | Priority: MEDIUM
3. [ ] Buy groceries | Due: 2024-12-10 | Priority: LOW
- View the list of tasks
- Enter the task number to mark as complete
- Task will be marked with
[done]prefix
- View the list of tasks
- Enter the task number to delete
- Confirm deletion with
yesorno - Deleted task is saved for undo functionality
- Restores the most recently deleted task
- Multiple undos supported (Stack-based implementation)
- Tasks are restored with original priority and position
- Saves all tasks automatically
- Closes the application
- HIGH: Urgent and important tasks
- MEDIUM: Important but not urgent
- LOW: Nice to have tasks
Tasks are automatically sorted using a custom Comparable implementation:
- First by priority (HIGH → MEDIUM → LOW)
- Then by due date (earliest first)
- Tasks are saved to
tasks.txtafter every operation - File format:
[status] description | Due: date | Priority: level - Automatically loads tasks on startup
- Uses a Stack data structure to store deleted tasks
- Supports multiple consecutive undos
- Restores tasks with original properties
- Implements
SerializableandComparable<Task> - Properties: description, isDone, dueDate, priority
- Custom sorting logic based on priority and due date
- Formatted string representation
- Main CLI interface with menu-driven navigation
- Input validation and error handling
- Stack-based undo functionality
- Integrates with TaskStorage for persistence
- Handles file I/O operations
- Loads tasks from
tasks.txton startup - Saves tasks after each operation
- Parses task format from file
- ArrayList: For storing the main task list
- Stack: For implementing undo functionality
- LocalDate: For date handling and formatting
- Enum: For priority levels
# Start the program
$ java TaskManager
# Add a high-priority task
1. Add Task
Enter task description: Submit project report
Enter due date (YYYY-MM-DD): 2024-12-20
Enter priority (LOW, MEDIUM, HIGH): HIGH
Task added successfully.
# List all tasks
2. List Tasks
1. [ ] Submit project report | Due: 2024-12-20 | Priority: HIGH
# Mark task as done
3. Mark Task as Done
Enter task number to mark as done: 1
Task marked as done.
# Delete a task
4. Delete Task
Enter task number to delete: 1
Are you sure you want to delete this task? (yes/no): yes
Task deleted. You can undo this action.
# Undo deletion
5. Undo Last Deletion
Task restored successfully!Edit the Priority enum in Task.java:
public enum Priority { LOW, MEDIUM, HIGH, URGENT, CRITICAL }Modify the FILE_NAME constant in TaskStorage.java:
private static final String FILE_NAME = "path/to/your/tasks.txt";Update the DateTimeFormatter in Task.java:
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");The application handles:
- ✅ Invalid menu choices
- ✅ Invalid date formats
- ✅ Invalid priority values
- ✅ Invalid task numbers
- ✅ Empty task lists
- ✅ File I/O errors
- ✅ Non-numeric input
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch
git checkout -b feature/AmazingFeature- Commit your changes
git commit -m 'Add some AmazingFeature'- Push to the branch
git push origin feature/AmazingFeature- Open a Pull Request
- 🎨 Add color-coded output for priorities
- 📊 Add task statistics and reports
- 🔍 Implement search functionality
- 📱 Add recurring tasks feature
- 🌐 Export tasks to different formats (JSON, CSV)
- ⏰ Add reminder notifications
- 🏷️ Add task categories/tags
Your Name
- GitHub: @Swapnilden
- LinkedIn: Swapnil Srivastava
- Email: swapnil9srivastava@gmail.com
- Java SE Documentation for best practices
- Stack Overflow community for problem-solving insights
- Open source community for inspiration
If you're new to Java or want to understand the concepts used:
- Add task categories/tags
- Implement recurring tasks
- Add task search and filter
- Color-coded priority display
- Export to JSON/CSV
- Task statistics dashboard
- Email notifications
- Multi-user support
- GUI version using JavaFX
Made with ☕ and Java
Happy Task Managing! 📝