Learning coding means GreatToCode Be more than a Coder ! Greattocode , Join GreatToCode Community,1000+ Students Trusted On Us .If You want to learn coding, Then GreatToCode Help You.No matter what It Takes !


CODE YOUR WAY TO A MORE FULFILLING And HIGHER PAYING CAREER IN TECH, START CODING FOR FREE Camp With GreatToCode - Join the Thousands learning to code with GreatToCode
Interactive online coding classes for at-home learning with GreatToCode . Try ₹Free Per Month Coding Classes With The Top Teachers . To - do list software In Java.

To - do list software In Java.

Let's create a simple to-do list software in Java. This software will allow you to manage tasks by adding, completing, and viewing them. Here's an example implementation to get you started:

```java
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Task {
    private String description;
    private boolean isCompleted;

    public Task(String description) {
        this.description = description;
        this.isCompleted = false;
    }

    public String getDescription() {
        return description;
    }

    public boolean isCompleted() {
        return isCompleted;
    }

    public void markAsCompleted() {
        isCompleted = true;
    }
}

public class ToDoList {
    private List<Task> tasks;

    public ToDoList() {
        this.tasks = new ArrayList<>();
    }

    public void addTask(String description) {
        Task task = new Task(description);
        tasks.add(task);
        System.out.println("Task added: " + description);
    }

    public void completeTask(int index) {
        if (index >= 0 && index < tasks.size()) {
            Task task = tasks.get(index);
            task.markAsCompleted();
            System.out.println("Task completed: " + task.getDescription());
        } else {
            System.out.println("Invalid task index.");
        }
    }

    public void viewTasks() {
        if (tasks.isEmpty()) {
            System.out.println("No tasks found.");
        } else {
            System.out.println("Tasks:");
            for (int i = 0; i < tasks.size(); i++) {
                Task task = tasks.get(i);
                String status = task.isCompleted() ? "[X]" : "[ ]";
                System.out.println(i + ". " + status + " " + task.getDescription());
            }
        }
    }

    public static void main(String[] args) {
        ToDoList toDoList = new ToDoList();
        Scanner scanner = new Scanner(System.in);

        while (true) {
            System.out.println("To-Do List");
            System.out.println("1. Add Task");
            System.out.println("2. Complete Task");
            System.out.println("3. View Tasks");
            System.out.println("4. Exit");
            System.out.print("Enter your choice: ");
            int choice = scanner.nextInt();
            scanner.nextLine(); // Consume newline

            switch (choice) {
                case 1:
                    System.out.print("Enter task description: ");
                    String description = scanner.nextLine();
                    toDoList.addTask(description);
                    break;
                case 2:
                    System.out.print("Enter task index: ");
                    int index = scanner.nextInt();
                    toDoList.completeTask(index);
                    break;
                case 3:
                    toDoList.viewTasks();
                    break;
                case 4:
                    System.exit(0);
                    break;
                default:
                    System.out.println("Invalid choice. Please try again.");
                    break;
            }
            System.out.println();
        }
    }
}
```

In this implementation, the `Task` class represents a single task with a description and completion status. The `ToDoList` class manages the collection of tasks, allowing you to add tasks, mark them as completed, and view the tasks. The main method sets up a simple console-based user interface to interact with the to-do list functionality.

Post a Comment

0 Comments

•Give The opportunity to your child with GreatToCode Kid's • Online Coding Classes for Your Kid • Introduce Your kid To the world's of coding
•Fuel You Career with our 100+ Hiring Partners, Advance Your Career in Tech with GreatToCode. •Join The Largest Tech and coding Community and Fast Forward Your career with GreatToCode. •10000+ Learner's+ 90 % placement Guarantee. • Learning Coding is Better with the GreatToCode community .
•Greattocode Kid's •GreatToCode Career •GreatToCode Interview •GreatToCode Professional •GreatToCode for schools •GreatToCode For colleges •GreatToCods For Businesses.
Are you ready to join the millions of people learning to code? GreatToCode Pass is your one-stop-shop to get access to 1000+ courses, top-notch support, and successful job placement. What are you waiting for? Sign up now and get your future in motion with GreatToCode Pass.

Join Arvind Upadhyay Succedo Event & Movement

Unlock Your True Potential!

Are you ready to transform your life and achieve the success you deserve?

Join us for an empowering experience!

Event Details:

Date: 25th October 2024

Time: 3 PM to 4 PM

Price/Ticket: Rs 100

Virtual Event

Lifetime Guidance

Pay just Rs 100 to join via UPI:

Pay via UPI

Register by emailing: ceoarvindenterprises@gmail.com

Chat with our team on WhatsApp for more information:

918080772353

Register Now Chat on WhatsApp

Event by Arvind Upadhyay.

Arvind Upadhyay is the author of over 100 books, a business and life coach, and famous for his self-help books, high-energy seminars, and workshops.

Attract Health, Wealth, and Success

Using the Law of Attraction

Are you struggling to become successful, despite having all the knowledge and skills?

It might be because you’re not using the most powerful principle known to mankind.

Join Our Virtual Event!

Available in Hindi and English

Date: 20th Oct 2024

Time: 10 AM to 11 AM

Pay just Rs 50 to join via UPI:

Pay via UPI

Register by emailing: ceoarvindenterprises@gmail.com

Chat with our team on WhatsApp for more information:

918080772353

Register Now Chat on WhatsApp

Event by Arvind Upadhyay.

Arvind Upadhyay is the author of over 100 books, a business and life coach, and famous for his self-help books, high-energy seminars, and workshops.