content: import java.util.ArrayList;
  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 completeTask() {
          this.isCompleted = true;
      }
  
      @Override
      public String toString() {
          return (isCompleted ? "[x] " : "[ ] ") + description;
      }
  }
  
  public class ToDoList {
      private ArrayList<Task> tasks;
  
      public ToDoList() {
          tasks = new ArrayList<>();
      }
  
      public void addTask(String description) {
          tasks.add(new Task(description));
      }
  
      public void completeTask(int index) {
          if (index >= 0 && index < tasks.size()) {
              tasks.get(index).completeTask();
          } else {
              System.out.println("Invalid task number.");
          }
      }
  
      public void showTasks() {
          for (int i = 0; i < tasks.size(); i++) {
              System.out.println((i + 1) + ". " + tasks.get(i));
          }
      }
  
      public static void main(String[] args) {
          ToDoList toDoList = new ToDoList();
          Scanner scanner = new Scanner(System.in);
          int choice;
  
          do {
              System.out.println("1. Add Task\n2. Complete Task\n3. Show Tasks\n4. Exit\nChoose an option: ");
              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 number to complete: ");
                      int taskNumber = scanner.nextInt();
                      toDoList.completeTask(taskNumber - 1);
                      break;
                  case 3:
                      toDoList.showTasks();
                      break;
              }
          } while (choice != 4);
  
          scanner.close();
      }
  }
  