Class MainRegister

java.lang.Object
ntnu.team1.backend.MainRegister
All Implemented Interfaces:
Serializable

public class MainRegister extends Object implements Serializable
This is is the main register of the application It keeps track of all categories in a HashMap and tasks in an ArrayList The Mainregister also allows for adding tasks and adding categories to the register It also handles saving and reading from file, it also sorts the registers
See Also:
Serialized Form
  • Constructor Details

    • MainRegister

      public MainRegister()
      Constructor for MainRegister Instantiates categories and tasks
  • Method Details

    • getCategory

      public Category getCategory(int id)
      Returns a category according to the id
      Parameters:
      id - id of the category
      Returns:
      the category associated with the id
    • getTask

      public Task getTask(int id) throws IllegalArgumentException
      Returns a task according to the id
      Parameters:
      id - id of the task
      Returns:
      the task associated with the id
      Throws:
      IllegalArgumentException
    • addTask

      public void addTask(LocalDate startDate, LocalDate endDate, String name, String description, int priority, int categoryId) throws NullPointerException
      Method for adding a task to the register
      Parameters:
      startDate - A LocalDate object representing the start date of the Task
      endDate - A LocalDate object representing the end date of the Task
      name - A string representing the name of the Task
      description - A String representing the description of the Task
      priority - An integer representing the priority of the Task
      categoryId - An Integer representing the ID of a category
      Throws:
      NullPointerException - If the name is null the Task will not be added
    • editTask

      public void editTask(int id, LocalDate startDate, LocalDate endDate, String name, String description, int priority, int categoryId) throws NullPointerException
      Method for editing a task
      Parameters:
      id - an Integer representing the ID of a main task
      startDate - A LocalDate object representing the start date of the Task
      endDate - A LocalDate object representing the end date of the Task
      name - A string representing the name of the Task
      description - A String representing the description of the Task
      priority - An integer representing the priority of the Task
      categoryId - An Integer representing the ID of a category
      Throws:
      NullPointerException
    • editCategory

      public void editCategory(Category updatedCategory)
      Method for editing a category
      Parameters:
      updatedCategory - The category we want to replace with existing one
    • removeTask

      public void removeTask(int taskId) throws IllegalArgumentException
      Removes a task from the register
      Parameters:
      taskId - Id associated with the task
      Throws:
      IllegalArgumentException
    • getAllTasks

      public ArrayList<Task> getAllTasks()
      Gets all tasks
      Returns:
      Returns all tasks
    • addCategory

      public boolean addCategory(String name, javafx.scene.paint.Color color) throws NullPointerException
      Adds a category to the register
      Parameters:
      name - The name of the category
      color - The color associated with the category
      Returns:
      Returns true if the category was registered, returns false if it failed
      Throws:
      NullPointerException
    • getCategories

      public HashMap<Integer,​Category> getCategories()
      Gets the categories
      Returns:
      Catgories
    • removeCategory

      public void removeCategory(int id) throws RemoveException
      Removes a category
      Parameters:
      id - Id of category
      Throws:
      RemoveException - Thrown if it cant remove
    • setCategories

      public void setCategories(HashMap<Integer,​Category> categories)
      Sets the category list
      Parameters:
      categories - Category List we want to set
    • setTasks

      public void setTasks(ArrayList<Task> tasks)
      Sets the task list
      Parameters:
      tasks - Task list we want to set
    • toString

      public String toString()
      To-String for the object
      Overrides:
      toString in class Object
      Returns:
      All usefull information as a String