Class SolutionModel
java.lang.Object
dev.zemco.codegame.presentation.solution.SolutionModel
- All Implemented Interfaces:
ISolutionModel
Implementation of
solution model evaluating solution created by player.
Target problem is provided by the problem list model.
This model uses the provided IProgramCompiler for compilation and IEvaluationService for evaluation.- Author:
- Erik Zemčík
- See Also:
-
Property Summary
PropertiesTypePropertyDescriptionjavafx.beans.value.ObservableBooleanValueProperty indicating if compilation of player's solution is available.javafx.beans.value.ObservableBooleanValueProperty indicating if test evaluation of player's solution is available.javafx.beans.value.ObservableBooleanValueProperty indicating if test evaluation of player's solution can be stepped.javafx.beans.value.ObservableBooleanValueProperty indicating if of player's solution can be submitted.javafx.beans.value.ObservableBooleanValueProperty indicating if test evaluation of player's solution is running.javafx.beans.value.ObservableObjectValue<ISolutionErrorModel>Property holding the lastsolution error modelindicating error during execution of the test evaluation of player's solution.javafx.beans.value.ObservableObjectValue<javafx.collections.ObservableList<IMemoryCellObserver>>Property holdingmemory cell observersfor 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 targetproblemthat is being solved.javafx.beans.value.ObservableObjectValue<ISolutionErrorModel>Property holding the lastsolution error modelindicating syntax error in the player's solution source code. -
Constructor Summary
ConstructorsConstructorDescriptionSolutionModel(IProblemListModel problemListModel, IProgramCompiler programCompiler, IEvaluationService evaluationService, ISolutionErrorModelFactory programErrorModelFactory) Creates an instance ofSolutionModel. -
Method Summary
Modifier and TypeMethodDescriptionjavafx.beans.value.ObservableBooleanValueProperty indicating if compilation of player's solution is available.javafx.beans.value.ObservableBooleanValueProperty indicating if test evaluation of player's solution is available.javafx.beans.value.ObservableBooleanValueProperty indicating if test evaluation of player's solution can be stepped.javafx.beans.value.ObservableBooleanValueProperty indicating if of player's solution can be submitted.voidcompileSolution(String sourceCode) Attempts to compile the player's solution.javafx.beans.value.ObservableBooleanValueProperty indicating if test evaluation of player's solution is running.javafx.beans.value.ObservableObjectValue<ISolutionErrorModel>Property holding the lastsolution error modelindicating error during execution of the test evaluation of player's solution.javafx.beans.value.ObservableObjectValue<javafx.collections.ObservableList<IMemoryCellObserver>>Property holdingmemory cell observersfor 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 targetproblemthat is being solved.voidTriggers a new solution attempt.voidStarts test evaluation of the player's solution on test problem case.voidSteps test evaluation of the player's solution.voidStops test evaluation of the player's solution.booleanAttempts to submit the player's solution.javafx.beans.value.ObservableObjectValue<ISolutionErrorModel>Property holding the lastsolution error modelindicating syntax error in the player's solution source code.
-
Property Details
-
problem
- Specified by:
problemPropertyin interfaceISolutionModel
-
canCompile
public javafx.beans.value.ObservableBooleanValue canCompileProperty- Specified by:
canCompilePropertyin interfaceISolutionModel
-
canEvaluate
public javafx.beans.value.ObservableBooleanValue canEvaluateProperty- Specified by:
canEvaluatePropertyin interfaceISolutionModel
-
canStep
public javafx.beans.value.ObservableBooleanValue canStepProperty- Specified by:
canStepPropertyin interfaceISolutionModel
-
evaluationRunning
public javafx.beans.value.ObservableBooleanValue evaluationRunningProperty- Specified by:
evaluationRunningPropertyin interfaceISolutionModel
-
canSubmit
public javafx.beans.value.ObservableBooleanValue canSubmitProperty- Specified by:
canSubmitPropertyin interfaceISolutionModel
-
nextInstructionLinePosition
- Specified by:
nextInstructionLinePositionPropertyin interfaceISolutionModel
-
memoryCells
public javafx.beans.value.ObservableObjectValue<javafx.collections.ObservableList<IMemoryCellObserver>> memoryCellsProperty- Specified by:
memoryCellsPropertyin interfaceISolutionModel
-
syntaxError
- Specified by:
syntaxErrorPropertyin interfaceISolutionModel
-
executionError
- Specified by:
executionErrorPropertyin interfaceISolutionModel
-
-
Constructor Details
-
SolutionModel
public SolutionModel(IProblemListModel problemListModel, IProgramCompiler programCompiler, IEvaluationService evaluationService, ISolutionErrorModelFactory programErrorModelFactory) Creates an instance ofSolutionModel.- Parameters:
problemListModel- source of the targetproblemprogramCompiler- compiler for compilation of player's solution source codeevaluationService- service for evaluating the player's solutionprogramErrorModelFactory- factory for creating errors indicating details about failure of player's solution- Throws:
IllegalArgumentException- if any parameter isnull
-
-
Method Details
-
resetAttempt
public void resetAttempt()Description copied from interface:ISolutionModelTriggers a new solution attempt.- Specified by:
resetAttemptin interfaceISolutionModel
-
compileSolution
Description copied from interface:ISolutionModelAttempts to compile the player's solution. Availability of compilation can be checked via thecan compile property.- Specified by:
compileSolutionin interfaceISolutionModel- Parameters:
sourceCode- source code of the player's solution
-
startTestEvaluation
public void startTestEvaluation()Description copied from interface:ISolutionModelStarts test evaluation of the player's solution on test problem case. Availability of test evaluation can be checked via thecan evaluate property.- Specified by:
startTestEvaluationin interfaceISolutionModel
-
stepTestEvaluation
public void stepTestEvaluation()Description copied from interface:ISolutionModelSteps test evaluation of the player's solution. Test evaluation can be stepped when it isrunning.- Specified by:
stepTestEvaluationin interfaceISolutionModel
-
stopTestEvaluation
public void stopTestEvaluation()Description copied from interface:ISolutionModelStops test evaluation of the player's solution. Test evaluation can be stopped when it isrunning.- Specified by:
stopTestEvaluationin interfaceISolutionModel
-
submitSolution
public boolean submitSolution()Description copied from interface:ISolutionModelAttempts to submit the player's solution. If the submission succeeds, the solution is considered valid for the givenproblem. Availability of submission can be checked via thecan submit property.- Specified by:
submitSolutionin interfaceISolutionModel- Returns:
- true if the submission succeeded, else false
-
problemProperty
Description copied from interface:ISolutionModelProperty holding the targetproblemthat is being solved.- Specified by:
problemPropertyin interfaceISolutionModel
-
canCompileProperty
public javafx.beans.value.ObservableBooleanValue canCompileProperty()Description copied from interface:ISolutionModelProperty indicating if compilation of player's solution is available.- Specified by:
canCompilePropertyin interfaceISolutionModel
-
canEvaluateProperty
public javafx.beans.value.ObservableBooleanValue canEvaluateProperty()Description copied from interface:ISolutionModelProperty indicating if test evaluation of player's solution is available.- Specified by:
canEvaluatePropertyin interfaceISolutionModel
-
canStepProperty
public javafx.beans.value.ObservableBooleanValue canStepProperty()Description copied from interface:ISolutionModelProperty indicating if test evaluation of player's solution can be stepped.- Specified by:
canStepPropertyin interfaceISolutionModel
-
evaluationRunningProperty
public javafx.beans.value.ObservableBooleanValue evaluationRunningProperty()Description copied from interface:ISolutionModelProperty indicating if test evaluation of player's solution is running.- Specified by:
evaluationRunningPropertyin interfaceISolutionModel
-
canSubmitProperty
public javafx.beans.value.ObservableBooleanValue canSubmitProperty()Description copied from interface:ISolutionModelProperty indicating if of player's solution can be submitted.- Specified by:
canSubmitPropertyin interfaceISolutionModel
-
nextInstructionLinePositionProperty
Description copied from interface:ISolutionModelProperty indicating next instruction line position to execute during test evaluation of player's solution. This property may holdnullwhen the position is not available.- Specified by:
nextInstructionLinePositionPropertyin interfaceISolutionModel
-
memoryCellsProperty
public javafx.beans.value.ObservableObjectValue<javafx.collections.ObservableList<IMemoryCellObserver>> memoryCellsProperty()Description copied from interface:ISolutionModelProperty holdingmemory cell observersfor observing memory state during the test evaluation. This property may holdnullwhen the evaluation is not running.- Specified by:
memoryCellsPropertyin interfaceISolutionModel
-
syntaxErrorProperty
Description copied from interface:ISolutionModelProperty holding the lastsolution error modelindicating syntax error in the player's solution source code. This property may holdnullif no syntax error was found for the current solution.- Specified by:
syntaxErrorPropertyin interfaceISolutionModel
-
executionErrorProperty
Description copied from interface:ISolutionModelProperty holding the lastsolution error modelindicating error during execution of the test evaluation of player's solution. This property may holdnullif no execution error was found at the current state of evaluation.- Specified by:
executionErrorPropertyin interfaceISolutionModel
-