Package ntnu.team1.backend
Class MainRegister
java.lang.Object
ntnu.team1.backend.MainRegister
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionConstructor for MainRegister Instantiates categories and tasks -
Method Summary
Modifier and TypeMethodDescriptionboolean
addCategory(String name, javafx.scene.paint.Color color)
Adds a category to the registervoid
addTask(LocalDate startDate, LocalDate endDate, String name, String description, int priority, int categoryId)
Method for adding a task to the registervoid
editCategory(Category updatedCategory)
Method for editing a categoryvoid
editTask(int id, LocalDate startDate, LocalDate endDate, String name, String description, int priority, int categoryId)
Method for editing a taskGets all tasksGets the categoriesgetCategory(int id)
Returns a category according to the idgetTask(int id)
Returns a task according to the idvoid
removeCategory(int id)
Removes a categoryvoid
removeTask(int taskId)
Removes a task from the registervoid
setCategories(HashMap<Integer,Category> categories)
Sets the category listvoid
Sets the task listtoString()
To-String for the object
-
Constructor Details
-
MainRegister
public MainRegister()Constructor for MainRegister Instantiates categories and tasks
-
-
Method Details
-
getCategory
Returns a category according to the id- Parameters:
id
- id of the category- Returns:
- the category associated with the id
-
getTask
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 NullPointerExceptionMethod for adding a task to the register- Parameters:
startDate
- A LocalDate object representing the start date of the TaskendDate
- A LocalDate object representing the end date of the Taskname
- A string representing the name of the Taskdescription
- A String representing the description of the Taskpriority
- An integer representing the priority of the TaskcategoryId
- 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 NullPointerExceptionMethod for editing a task- Parameters:
id
- an Integer representing the ID of a main taskstartDate
- A LocalDate object representing the start date of the TaskendDate
- A LocalDate object representing the end date of the Taskname
- A string representing the name of the Taskdescription
- A String representing the description of the Taskpriority
- An integer representing the priority of the TaskcategoryId
- An Integer representing the ID of a category- Throws:
NullPointerException
-
editCategory
Method for editing a category- Parameters:
updatedCategory
- The category we want to replace with existing one
-
removeTask
Removes a task from the register- Parameters:
taskId
- Id associated with the task- Throws:
IllegalArgumentException
-
getAllTasks
Gets all tasks- Returns:
- Returns all tasks
-
addCategory
public boolean addCategory(String name, javafx.scene.paint.Color color) throws NullPointerExceptionAdds a category to the register- Parameters:
name
- The name of the categorycolor
- The color associated with the category- Returns:
- Returns true if the category was registered, returns false if it failed
- Throws:
NullPointerException
-
getCategories
Gets the categories- Returns:
- Catgories
-
removeCategory
Removes a category- Parameters:
id
- Id of category- Throws:
RemoveException
- Thrown if it cant remove
-
setCategories
Sets the category list- Parameters:
categories
- Category List we want to set
-
setTasks
Sets the task list- Parameters:
tasks
- Task list we want to set
-
toString
To-String for the object
-