From d71903eabaff6b4bfaeea3a2c0a089f9a71be304 Mon Sep 17 00:00:00 2001
From: Harry Linrui XU <xulr0820@hotmail.com>
Date: Sat, 1 Apr 2023 09:42:11 +0200
Subject: [PATCH] Added returnToMainMenu method into interface. Added javadoc

---
 .../ntnu/idatt1002/demo/controller/BudgetController.java   | 5 ++---
 .../ntnu/idatt1002/demo/controller/FinanceController.java  | 7 +++++++
 .../idatt1002/demo/controller/IncomeExpenseController.java | 6 ++++--
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/BudgetController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/BudgetController.java
index 8c246989..a638dcf3 100644
--- a/src/main/java/no/ntnu/idatt1002/demo/controller/BudgetController.java
+++ b/src/main/java/no/ntnu/idatt1002/demo/controller/BudgetController.java
@@ -266,9 +266,8 @@ public class BudgetController implements FinanceController {
     }
 
     /**
-     * Switches scenes from the budget scene to another, by loading a new FXML file and setting the scene to this location.
-     * The destination depends entirely on which button is pressed.
-     * @param event A button click on the buttons on the buttonbar or the next button
+     * Switches scenes back to main menu, by loading a new FXML file and setting the scene to this location.
+     * @param event A button click on the return to main menu button
      * @throws IOException If an error occurs with loading any of the FXML files.
      */
    @FXML
diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/FinanceController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/FinanceController.java
index 96efb651..09b60937 100644
--- a/src/main/java/no/ntnu/idatt1002/demo/controller/FinanceController.java
+++ b/src/main/java/no/ntnu/idatt1002/demo/controller/FinanceController.java
@@ -49,4 +49,11 @@ public interface FinanceController {
    * @throws IOException If an error occurs while writing to the file.
    */
   void saveDataToFile() throws IOException;
+
+  /**
+   * Switches scenes back to main menu, by loading a new FXML file and setting the scene to this location.
+   * @param event A button click on the return to main menu button
+   * @throws IOException If an error occurs with loading any of the FXML files.
+   */
+  void returnToMainMenu(javafx.event.ActionEvent event) throws IOException;
 }
diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/IncomeExpenseController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/IncomeExpenseController.java
index 5e5760a0..ae01c334 100644
--- a/src/main/java/no/ntnu/idatt1002/demo/controller/IncomeExpenseController.java
+++ b/src/main/java/no/ntnu/idatt1002/demo/controller/IncomeExpenseController.java
@@ -517,10 +517,12 @@ public class IncomeExpenseController implements FinanceController {
   }
 
   /**
-   * Switches the scene to the Main Menu scene.
+   * Switches scenes back to main menu, by loading a new FXML file and setting the scene to this location.
+   * @param event A button click on the return to main menu button
+   * @throws IOException If an error occurs with loading any of the FXML files.
    */
   @FXML
-  private void returnToMainMenu(javafx.event.ActionEvent event) throws IOException {
+  public void returnToMainMenu(javafx.event.ActionEvent event) throws IOException {
     saveDataToFile();
     FXMLLoader loader = new FXMLLoader();
     loader.setLocation(getClass().getResource("/view/MainMenuNew.fxml"));
-- 
GitLab