Interface ISolutionModel

All Known Implementing Classes:
SolutionModel

public interface ISolutionModel
Manages logic and state related to user's solution to a given problem. Problem being solved is accessible via problemProperty().

A new solution should be triggered by resetAttempt(). Each solution attempt to be compiled via compileSolution(String). Availability of compilation should be checked through canCompileProperty(). If the compilation fails, related error information is accessible through syntaxErrorProperty().

For a given solution attempt, test evaluation is possible, and can be started using startTestEvaluation(). Availability of starting the test evaluation should be checked through canEvaluateProperty(). Information about the state of the evaluation is available through nextInstructionLinePositionProperty(), memoryCellsProperty(), and evaluationRunningProperty(). Evaluation can be stepped via stepTestEvaluation(), when indicated via canStepProperty(). If the evaluation encounters an execution error, the error becomes available through executionErrorProperty(). Evaluation can be stopped via stopTestEvaluation().

Solution can be submitted via submitSolution(), when indicated via canSubmitProperty().

Author:
Erik Zemčík
  • Property Summary

    Properties
    Type
    Property
    Description
    javafx.beans.value.ObservableBooleanValue
    Property indicating if compilation of player's solution is available.
    javafx.beans.value.ObservableBooleanValue
    Property indicating if test evaluation of player's solution is available.
    javafx.beans.value.ObservableBooleanValue
    Property indicating if test evaluation of player's solution can be stepped.
    javafx.beans.value.ObservableBooleanValue
    Property indicating if of player's solution can be submitted.
    javafx.beans.value.ObservableBooleanValue
    Property indicating if test evaluation of player's solution is running.
    javafx.beans.value.ObservableObjectValue<ISolutionErrorModel>
    Property holding the last solution error model indicating error during execution of the test evaluation of player's solution.
    javafx.beans.value.ObservableObjectValue<javafx.collections.ObservableList<IMemoryCellObserver>>
    Property holding memory cell observers for observing memory state during the test evaluation.
    javafx.beans.value.ObservableObjectValue<Integer>
    Property indicating next instruction line position to execute during test evaluation of player's solution.
    javafx.beans.value.ObservableObjectValue<Problem>
    Property holding the target problem that is being solved.
    javafx.beans.value.ObservableObjectValue<ISolutionErrorModel>
    Property holding the last solution error model indicating syntax error in the player's solution source code.
  • Method Summary

    Modifier and Type
    Method
    Description
    javafx.beans.value.ObservableBooleanValue
    Property indicating if compilation of player's solution is available.
    javafx.beans.value.ObservableBooleanValue
    Property indicating if test evaluation of player's solution is available.
    javafx.beans.value.ObservableBooleanValue
    Property indicating if test evaluation of player's solution can be stepped.
    javafx.beans.value.ObservableBooleanValue
    Property indicating if of player's solution can be submitted.
    void
    compileSolution(String sourceCode)
    Attempts to compile the player's solution.
    javafx.beans.value.ObservableBooleanValue
    Property indicating if test evaluation of player's solution is running.
    javafx.beans.value.ObservableObjectValue<ISolutionErrorModel>
    Property holding the last solution error model indicating error during execution of the test evaluation of player's solution.
    javafx.beans.value.ObservableObjectValue<javafx.collections.ObservableList<IMemoryCellObserver>>
    Property holding memory cell observers for observing memory state during the test evaluation.
    javafx.beans.value.ObservableObjectValue<Integer>
    Property indicating next instruction line position to execute during test evaluation of player's solution.
    javafx.beans.value.ObservableObjectValue<Problem>
    Property holding the target problem that is being solved.
    void
    Triggers a new solution attempt.
    void
    Starts test evaluation of the player's solution on test problem case.
    void
    Steps test evaluation of the player's solution.
    void
    Stops test evaluation of the player's solution.
    boolean
    Attempts to submit the player's solution.
    javafx.beans.value.ObservableObjectValue<ISolutionErrorModel>
    Property holding the last solution error model indicating syntax error in the player's solution source code.
  • Property Details

    • problem

      javafx.beans.value.ObservableObjectValue<Problem> problemProperty
      Property holding the target problem that is being solved.
    • canCompile

      javafx.beans.value.ObservableBooleanValue canCompileProperty
      Property indicating if compilation of player's solution is available.
    • canEvaluate

      javafx.beans.value.ObservableBooleanValue canEvaluateProperty
      Property indicating if test evaluation of player's solution is available.
    • canStep

      javafx.beans.value.ObservableBooleanValue canStepProperty
      Property indicating if test evaluation of player's solution can be stepped.
    • evaluationRunning

      javafx.beans.value.ObservableBooleanValue evaluationRunningProperty
      Property indicating if test evaluation of player's solution is running.
    • canSubmit

      javafx.beans.value.ObservableBooleanValue canSubmitProperty
      Property indicating if of player's solution can be submitted.
    • nextInstructionLinePosition

      javafx.beans.value.ObservableObjectValue<Integer> nextInstructionLinePositionProperty
      Property indicating next instruction line position to execute during test evaluation of player's solution. This property may hold null when the position is not available.
    • memoryCells

      javafx.beans.value.ObservableObjectValue<javafx.collections.ObservableList<IMemoryCellObserver>> memoryCellsProperty
      Property holding memory cell observers for observing memory state during the test evaluation. This property may hold null when the evaluation is not running.
    • syntaxError

      javafx.beans.value.ObservableObjectValue<ISolutionErrorModel> syntaxErrorProperty
      Property holding the last solution error model indicating syntax error in the player's solution source code. This property may hold null if no syntax error was found for the current solution.
    • executionError

      javafx.beans.value.ObservableObjectValue<ISolutionErrorModel> executionErrorProperty
      Property holding the last solution error model indicating error during execution of the test evaluation of player's solution. This property may hold null if no execution error was found at the current state of evaluation.
  • Method Details

    • resetAttempt

      void resetAttempt()
      Triggers a new solution attempt.
    • compileSolution

      void compileSolution(String sourceCode)
      Attempts to compile the player's solution. Availability of compilation can be checked via the can compile property.
      Parameters:
      sourceCode - source code of the player's solution
      Throws:
      IllegalArgumentException - if sourceCode is null
      IllegalStateException - if compilation is not available
    • startTestEvaluation

      void startTestEvaluation()
      Starts test evaluation of the player's solution on test problem case. Availability of test evaluation can be checked via the can evaluate property.
      Throws:
      IllegalStateException - if starting of test evaluation is not available
    • stepTestEvaluation

      void stepTestEvaluation()
      Steps test evaluation of the player's solution. Test evaluation can be stepped when it is running.
      Throws:
      IllegalStateException - if the execution is not running
    • stopTestEvaluation

      void stopTestEvaluation()
      Stops test evaluation of the player's solution. Test evaluation can be stopped when it is running.
      Throws:
      IllegalStateException - if the execution is not running
    • submitSolution

      boolean submitSolution()
      Attempts to submit the player's solution. If the submission succeeds, the solution is considered valid for the given problem. Availability of submission can be checked via the can submit property.
      Returns:
      true if the submission succeeded, else false
    • problemProperty

      javafx.beans.value.ObservableObjectValue<Problem> problemProperty()
      Property holding the target problem that is being solved.
    • canCompileProperty

      javafx.beans.value.ObservableBooleanValue canCompileProperty()
      Property indicating if compilation of player's solution is available.
    • canEvaluateProperty

      javafx.beans.value.ObservableBooleanValue canEvaluateProperty()
      Property indicating if test evaluation of player's solution is available.
    • canStepProperty

      javafx.beans.value.ObservableBooleanValue canStepProperty()
      Property indicating if test evaluation of player's solution can be stepped.
    • evaluationRunningProperty

      javafx.beans.value.ObservableBooleanValue evaluationRunningProperty()
      Property indicating if test evaluation of player's solution is running.
    • canSubmitProperty

      javafx.beans.value.ObservableBooleanValue canSubmitProperty()
      Property indicating if of player's solution can be submitted.
    • nextInstructionLinePositionProperty

      javafx.beans.value.ObservableObjectValue<Integer> nextInstructionLinePositionProperty()
      Property indicating next instruction line position to execute during test evaluation of player's solution. This property may hold null when the position is not available.
    • memoryCellsProperty

      javafx.beans.value.ObservableObjectValue<javafx.collections.ObservableList<IMemoryCellObserver>> memoryCellsProperty()
      Property holding memory cell observers for observing memory state during the test evaluation. This property may hold null when the evaluation is not running.
    • syntaxErrorProperty

      javafx.beans.value.ObservableObjectValue<ISolutionErrorModel> syntaxErrorProperty()
      Property holding the last solution error model indicating syntax error in the player's solution source code. This property may hold null if no syntax error was found for the current solution.
    • executionErrorProperty

      javafx.beans.value.ObservableObjectValue<ISolutionErrorModel> executionErrorProperty()
      Property holding the last solution error model indicating error during execution of the test evaluation of player's solution. This property may hold null if no execution error was found at the current state of evaluation.