A console-based task manager written in Java using object-oriented programming. Supports adding, completing, deleting, and filtering tasks with no external libraries or frameworks.
- Features
- Concepts Covered
- Project Structure
- How It Works
- Getting Started
- Usage
- Sample Output
- Limitations
| Feature | Description |
|---|---|
| Add Task | Insert a new task by title |
| View All Tasks | Display all tasks with completion status |
| Mark Complete | Mark a pending task as done |
| Delete Task | Remove a task by its number |
| View Pending | Filter and show only incomplete tasks |
| View Completed | Filter and show only finished tasks |
- Classes & Objects β
TaskandTodoListare separate classes, each with a clear responsibility - Encapsulation β
Taskfields areprivate; accessed only through public getter methods - ArrayList β dynamic list with no fixed size limit; grows and shrinks automatically
toString()override β controls how aTaskprints ([β]or[ ])- Scanner β reads user input from the console with input type validation
todo-list-java/
βββ Main.java # Contains Task, TodoList, and Main classes
βββ README.md
All three classes are in a single file for simplicity. The file compiles and runs with one command.
βββββββββββββββββββββββββββββββββββββββββββββββ
β Task β
β βββββββββββββββββββββββββββββββββββββββββ β
β - title : String (private) β
β - isCompleted : boolean (private) β
β βββββββββββββββββββββββββββββββββββββββββ β
β + getTitle() : String β
β + isCompleted() : boolean β
β + markComplete(): void β
β + toString() : String β "[β] title" β
βββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββ
β TodoList β
β βββββββββββββββββββββββββββββββββββββββββ β
β - tasks : ArrayList<Task> (private) β
β βββββββββββββββββββββββββββββββββββββββββ β
β + addTask(title) : void β
β + displayAll() : void β
β + markComplete(index) : void β
β + deleteTask(index) : void β
β + showPending() : void β
β + showCompleted() : void β
βββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββ
β Main β
β βββββββββββββββββββββββββββββββββββββββββ β
β + main(args) β menu loop + Scanner input β
βββββββββββββββββββββββββββββββββββββββββββββββ
| Array | ArrayList | |
|---|---|---|
| Size | Fixed at declaration | Grows/shrinks dynamically |
| Deletion | Manual shift required | remove(index) handles it |
| Syntax | tasks[i] |
tasks.get(i) |
This project uses ArrayList<Task> so there is no hard limit on the number of tasks.
When a task at index i is deleted, Java shifts all elements after it one position left automatically.
Before delete at index 1: ["Buy milk", "Call doctor", "Study Java"]
After delete at index 1: ["Buy milk", "Study Java"]
No manual shifting needed β unlike C arrays where you write the shift loop yourself.
- JDK 8 or higher installed
Check with:
java -versionjavac Main.javajava MainAfter running, you will see:
================================
TO-DO LIST APPLICATION
================================
--- MENU ---
1. Add Task
2. View All Tasks
3. Mark Task as Complete
4. Delete Task
5. View Pending Tasks
6. View Completed Tasks
7. Exit
Enter your choice:
Enter a number from 1 to 7 and follow the prompts.
Enter your choice: 1
Enter task title: Complete Java assignment
Task added: "Complete Java assignment"
Enter your choice: 1
Enter task title: Buy groceries
Task added: "Buy groceries"
--- TO-DO LIST ---
1. [ ] Complete Java assignment
2. [ ] Buy groceries
Total tasks: 2
Enter task number to mark complete: 1
Task marked complete: "Complete Java assignment"
--- TO-DO LIST ---
1. [β] Complete Java assignment
2. [ ] Buy groceries
Total tasks: 2
--- PENDING TASKS ---
2. [ ] Buy groceries
Enter task number to delete: 2
Deleted: "Buy groceries"
| Limitation | Details |
|---|---|
| No persistence | Tasks are stored in memory only; lost when the program exits |
| No edit | To rename a task, delete it and add a new one |
| Single user | No multi-user or session support |
To add persistence, tasks can be written to and read from a .txt or .csv file using FileWriter and BufferedReader β a straightforward next step.