Skip to content

prathima918-reddy/To-do-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

βœ… To-Do List Application in Java

Language Platform Status

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.


πŸ“‹ Table of Contents


Features

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

Concepts Covered

  • Classes & Objects β€” Task and TodoList are separate classes, each with a clear responsibility
  • Encapsulation β€” Task fields are private; accessed only through public getter methods
  • ArrayList β€” dynamic list with no fixed size limit; grows and shrinks automatically
  • toString() override β€” controls how a Task prints ([βœ“] or [ ])
  • Scanner β€” reads user input from the console with input type validation

Project Structure

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.


How It Works

Class Breakdown

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  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   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

ArrayList vs Array

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.

Deletion β€” How ArrayList.remove() Works

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.


Getting Started

Prerequisites

  • JDK 8 or higher installed

Check with:

java -version

Compile

javac Main.java

Run

java Main

Usage

After 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.


Sample Output

Adding Tasks

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"

View All

--- TO-DO LIST ---
1. [ ] Complete Java assignment
2. [ ] Buy groceries
Total tasks: 2

Mark Complete

Enter task number to mark complete: 1
Task marked complete: "Complete Java assignment"

View All After Marking

--- TO-DO LIST ---
1. [βœ“] Complete Java assignment
2. [ ] Buy groceries
Total tasks: 2

View Pending Only

--- PENDING TASKS ---
2. [ ] Buy groceries

Delete

Enter task number to delete: 2
Deleted: "Buy groceries"

Limitations

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.

About

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.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors