You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zanninso 87b526be74 docs: fix typos and adding more details 2 months ago
..
ExerciseRunner.java docs: adding subject and main 2 months ago
README.md docs: fix typos and adding more details 2 months ago

README.md

TodoList

Instructions

Write a class Task that has two attributes: description and status, with the corresponding getters and setters.

Write a class called TodoList that represents a to-do list. The class should be able to hold a specified number of tasks, each with a description and a status. Include methods to add tasks, set a task's status, update task descriptions, and display all tasks in a neat format showing their descriptions and statuses.

If the index is out of bound nothing happens.

The description length will be less or equal to 30 character. When the list is full nothing more will be added.

Expected Functions

enum TaskStatus {
    NEW, IN_PROGRESS, COMPLETED
}

public class Task {
    private String description;
    private TaskStatus status;

    public void setDescription(String description);
    // Getters and Setters
    // ...
}

public class TodoList {
    private Task[] tasks;
    private int capacity;

    public TodoList(int capacity);

    public void addTask(String description);

    public void setStatus(int index, TaskStatus status);

    public void setDescription(int index, String newDescription);

    public void displayTasks();
}

Usage

Here is a possible ExerciseRunner.java to test your TodoList class:

public class ExerciseRunner {
    public static void main(String[] args) {
        TodoList myList = new TodoList(3); // List can hold up to 3 tasks
        myList.addTask("Go grocery shopping");
        myList.addTask("Pay electricity bill");
        myList.setStatus(0, TaskStatus.COMPLETED); // Mark the first task as completed
        myList.setDescription(1, "Pay all utility bills"); // Update the description of the second task
        myList.displayTasks(); // Display the list of tasks
    }
}

and its output:

$ javac TaskList.java ExerciseRunner.java
$ java ExerciseRunner.java
Tasks:
Go grocery shopping               | COMPLETED
Pay all utility bills             | NEW