Module hw06

Class ListDemoModel

java.lang.Object
visitorDemoExercises.listFWVisitorExercises.model.ListDemoModel

public class ListDemoModel extends Object
ListFW demo app model
Author:
swong
  • Field Details

    • logger

      private ILogger logger
      logger to use
    • view

      private IViewAdapter view
      Adapter to the view
    • list0

      private IList list0
      Instance of first available host
    • list1

      private IList list1
      Instance of second available host
    • list2

      private IList list2
      Instance of third available host
    • accLoader

      private IObjectLoader<IAccumulator> accLoader
      Dynamic loader for accumulator classes
    • visLoader

      private IObjectLoader<IListAlgo> visLoader
      Dynamic loader for visitor classes
    • foldr

      private IListAlgo foldr
      The fold right algo
    • foldl

      private IListAlgo foldl
      The fold left algo
  • Constructor Details

    • ListDemoModel

      public ListDemoModel(IViewAdapter view)
      Constructor for the class
      Parameters:
      view - The view adapter
  • Method Details

    • start

      public void start()
      Start the model
    • runListAlgo

      public String runListAlgo(IList list, String classname, String param)
      Returns the result of a host list executing the given visitor with the given parameter
      Parameters:
      list - The host list object
      classname - The class name of the visitor to use, without the leading "listFW.visitor."
      param - An input parameter for the visitor execution
      Returns:
      The result of the visitor execution by the list.
    • runFoldR

      public String runFoldR(IList list, String classname, String param)
      Run the FoldRAlgo visitor on the given list using the given IAccumulator
      Parameters:
      list - The host list object
      classname - The class name of the accumulator to use, without the leading "listFW.visitor."
      param - A constructor parameter for an accumulator object. Must be a String that the constructor can then convert to whatever it needs.
      Returns:
      The result of the foldr visitor execution by the list.
    • runFoldL

      public String runFoldL(IList list, String classname, String param)
      Run the FoldLAlgo visitor on the given list using the given IAccumulator
      Parameters:
      list - The host list object
      classname - The class name of the accumulator to use, without the leading "listFW.visitor."
      param - A constructor parameter for an accumulator object. Must be a String that the constructor can then convert to whatever it needs.
      Returns:
      The result of the foldl visitor execution by the list.