Module hw06

Class LogicalOrHost

java.lang.Object
provided.utils.logic.impl.LogicalOrHost
All Implemented Interfaces:
ILogicalHost

public class LogicalOrHost extends Object implements ILogicalHost
An ILogicalHost that represents the logical OR of two ILogicalHosts. That is, the trueCase of the given visitor will be run if one of the trueCases of the given hosts runs. Otherwise, the false case of the given visitor will run.
Author:
swong
  • Field Details

  • Constructor Details

    • LogicalOrHost

      public LogicalOrHost(ILogicalHost hostA, ILogicalHost hostB)
      Construct the logical OR of the two hosts. Note that hostA is evaluated first and if true, hostB is not evaluated.
      Parameters:
      hostA - The first logical host
      hostB - The second logical host
  • Method Details

    • execute

      public <R,​ P> R execute(ILogicalVisitor<R,​P> vis, P param)
      Description copied from interface: ILogicalHost
      Call the appropriate case on the given visitor corresponding to the current state of the host.
      Specified by:
      execute in interface ILogicalHost
      Type Parameters:
      R - The return type of the visitor
      P - The input parameter type of the visitor
      Parameters:
      vis - The visitor to accept which has true and false cases.
      param - The input parameter to pass to the visitor's case that is called.
      Returns:
      The result from running the case of the visitor