Class Task

java.lang.Object
amadeus.workspace.Task
Direct Known Subclasses:
Deadline, Event, ToDo

public abstract class Task extends Object
Abstract base class representing a generic task.

This class provides the foundational properties and methods for tasks, including a name, completion status, and methods to update and display task details. Subclasses can extend this class to create specific task types (e.g., Deadline, Event, ToDo).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    The completion status of the task (true if complete, false if incomplete).
    protected String
    The name or description of the task.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Task(String input)
    Initializes a new Task with the given name.
    Task(String input, boolean done)
    Initializes a new Task with the given name and completion status.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract String
    Returns the details of the task.
    boolean
    Returns the completion status of the task.
    Returns the name or description of the task.
    void
    Prints the task's name and completion status to the console.
    abstract String
    Converts the task to a file-friendly format.
    Returns a string representation of the task, which is its name.
    void
    updateDone(boolean status)
    Updates the completion status of the task.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • name

      protected String name
      The name or description of the task.
    • isDone

      protected boolean isDone
      The completion status of the task (true if complete, false if incomplete).
  • Constructor Details

    • Task

      public Task(String input)
      Initializes a new Task with the given name. The task is marked as incomplete by default.
      Parameters:
      input - the name or description of the task; must not be null.
    • Task

      public Task(String input, boolean done)
      Initializes a new Task with the given name and completion status.
      Parameters:
      input - the name or description of the task; must not be null.
      done - a boolean indicating whether the task is completed (true) or not (false).
  • Method Details

    • getName

      public String getName()
      Returns the name or description of the task.
      Returns:
      the name or description of the task.
    • getDone

      public boolean getDone()
      Returns the completion status of the task.
      Returns:
      true if the task is complete, false otherwise.
    • getDetails

      public abstract String getDetails()
      Returns the details of the task.

      Subclasses must implement this method to provide task-specific details.

      Returns:
      the details of the task as a formatted string.
    • updateDone

      public void updateDone(boolean status)
      Updates the completion status of the task.
      Parameters:
      status - the new completion status (true for complete, false for incomplete).
    • toString

      public String toString()
      Returns a string representation of the task, which is its name.
      Overrides:
      toString in class Object
      Returns:
      The name or description of the task as a String.
    • printTask

      public void printTask()
      Prints the task's name and completion status to the console. If the task is complete, a checkmark (✔️) is displayed next to the name.
    • toFileFormat

      public abstract String toFileFormat()
      Converts the task to a file-friendly format.

      Subclasses must implement this method to provide a format suitable for saving to a file.

      Returns:
      a string representation of the task in a format suitable for saving to a file.