java.lang.Object
stud.ntnu.idatt1005.pantrypal.controllers.Controller
stud.ntnu.idatt1005.pantrypal.controllers.AddRecipeController
All Implemented Interfaces:
Observer

public class AddRecipeController extends Controller implements Observer
Controller class for the AddRecipeView. This class is responsible for handling the logic for the AddRecipeView.
  • Field Details

    • groceryRegister

      private GroceryRegister groceryRegister
    • stepRegister

      private StepRegister stepRegister
    • BUTTON_NOT_SUPPORTED

      private static final String BUTTON_NOT_SUPPORTED
      See Also:
    • view

      private stud.ntnu.idatt1005.pantrypal.views.AddRecipeView view
      The view for the AddRecipeController.
    • cookBookController

      private final CookbookController cookBookController
  • Constructor Details

    • AddRecipeController

      public AddRecipeController(ViewManager viewManager, CookbookController cookBookController)
      Constructor that takes in a ViewManager and a CookBookController. The viewManager is sent to the superclass Constructor. the AddRecipeView is created and rendered with the controller. The view is added to the viewManager.
      Parameters:
      viewManager - the ViewManager for the application
      cookBookController - the CookBookController for the application
  • Method Details

    • setRecipeToAddRecipeView

      public void setRecipeToAddRecipeView(Recipe recipe)
      Changes the view to a new AddRecipeView() with an already existing recipe to edit.
      Parameters:
      recipe - the recipe to edit
    • update

      public void update(ButtonEnum buttonEnum, Object object)
      Updates the observer based on the type of button pressed, and object associated object. If the object is a Recipe it will be added to the Cookbook. If the object is a Grocery it will be added/removed to/from the GroceryRegister, and the view will be re-rendered. If the object is a String it will be added/removed to/from the StepRegister, and the view will be re-rendered.
      Specified by:
      update in interface Observer
      Parameters:
      buttonEnum - the button type that was pressed
      object - the object that is associated with the button
    • update

      public void update(ButtonEnum buttonEnum)
      Updates the observer with the button that was pressed.
      Specified by:
      update in interface Observer
      Parameters:
      buttonEnum - the button that was pressed
    • rerender

      public void rerender()
      Re-renders the view with the current groceryRegister and stepRegister.