org.problets.domain.model.control.iteration
Class ForLoopModel

java.lang.Object
  extended by org.problets.domain.model.DomainModel
      extended by org.problets.domain.model.control.ControlModel
          extended by org.problets.domain.model.control.ConditionControl
              extended by org.problets.domain.model.control.iteration.AbstractLoopModel
                  extended by org.problets.domain.model.control.iteration.ForLoopModel
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
IForLoopModel, VBForLoopModel

public class ForLoopModel
extends AbstractLoopModel

Class: ForLoopModel Purpose: Class for for loops

Author:
Garrett Dancik, Modified by Greg Tomalesky, Amruth Kumar

Field Summary
static int IDENTITY
           
 
Fields inherited from class org.problets.domain.model.control.iteration.AbstractLoopModel
ASSIGNMENT_IN_CONDITION, CONST_CONDITION, DECLARATION_IN_CONDITION, INCORRECT_UPDATE, NO_UPDATE, NULL_CONDITION, TERMINAL_MODIFIED
 
Fields inherited from class org.problets.domain.model.control.ConditionControl
INCORRECT_TYPE
 
Fields inherited from class org.problets.domain.model.control.ControlModel
ABORT_EXECUTION, BREAK_EXECUTION, CONTINUE_EXECUTION, END_EXECUTION, INFINITE_EXECUTION, RETURN_EXECUTION, RUN_TIME_ERROR_EXECUTION, SKIP_EXECUTION
 
Fields inherited from class org.problets.domain.model.DomainModel
BOOLEAN, BREAKPOINT, CHARACTER, DOUBLE_PRECISION_REAL, ERROR_TYPE, EVAL_STATUS, expACTION, expASSIGNMENT, expAUTO_DEALLOCATION, expCALL, expCONDITION, expDECLARATION, expDEREFERENCING, expDYNAMIC_ALLOCATION, expDYNAMIC_ALLOCATION_INITIALIZATION, expDYNAMIC_DEALLOCATION, expELSE_CLAUSE, expERROR, expEXECUTION, expIF_CLAUSE, expINITIALIZATION, expINPUT, expPARAMETER_PASSING, expPRINT, expQUESTIONABLE, expREFERENCING, expRETURN, expRUNTIME_ERROR, expSEMANTIC_ERROR, expSYNTAX_ERROR, expUPDATE, MAX_OBJECT_IDENTITY, MIN_OBJECT_IDENTITY, QUADRUPLE_PRECISION_REAL, RUNTIME_ERROR, SEMANTIC_ERROR, SIGNED_INTEGER, SIGNED_LONG, SIGNED_SHORT, SINGLE_PRECISION_REAL, SYNTAX_ERROR, UNDEFINED_TYPE, UNSIGNED_INTEGER, UNSIGNED_LONG, UNSIGNED_SHORT, WARNING
 
Constructor Summary
ForLoopModel(ActivationRecord parent, HeapModel heap, java.lang.String in_template, int in_scopeType)
          public ForLoopModel(ActivationRecord parent, HeapModel heap, String in_template, int in_scopeType); The constructor for the ForLoopModel class
 
Method Summary
 ExecutionStatus explainInitial(RunEnv runEnv, Behavior behavior, boolean stepFlag, int lineNumber)
          public void explainInitial(Vector explanation, Vector errors, int lineNumber); This function handles explaining any declarations, initializations, or assignments in the for loop header
 ExecutionStatus explainProcess(RunEnv runEnv, Behavior behavior, boolean stepFlag)
          public void explainProcess(Vector explanation, OutputStream output, Vector errors) This function generates the explanation of the code for the student.
 ExecutionStatus explainUpdate(RunEnv runEnv, Behavior behavior, int lineNumber)
          public void explainUpdate(Vector explanation, Vector errors, int lineNumber); This function handles explaining any update that occurs in the for loop header
 void getCode(java.util.Vector codeText, OutputStream output)
          public void getCode(Vector codeText, OutputStream output) This function generates the code seen by the student
 java.lang.String getName()
          Get the name of this control construct - for generation of error menus
static boolean grade(java.lang.String template, java.lang.String code)
           
static void main(java.lang.String[] args)
           
 void parseHeader(java.lang.String header)
          protected void parseHeader(String header); Extract the initial, condition, and update parts of the For Loop Header
 
Methods inherited from class org.problets.domain.model.control.iteration.AbstractLoopModel
getLoopValues, getPossibleErrors
 
Methods inherited from class org.problets.domain.model.control.ControlModel
getCodeLength, getStartLineNumber
 
Methods inherited from class org.problets.domain.model.DomainModel
clone, getId, getIdName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IDENTITY

public static final int IDENTITY
See Also:
Constant Field Values
Constructor Detail

ForLoopModel

public ForLoopModel(ActivationRecord parent,
                    HeapModel heap,
                    java.lang.String in_template,
                    int in_scopeType)
public ForLoopModel(ActivationRecord parent, HeapModel heap, String in_template, int in_scopeType); The constructor for the ForLoopModel class

Parameters:
parent - - an Activation record passed from the parent
heap - - the heap object used
in_template - - holds the for loop template
in_scopeType - - the scope type for this scope object
Method Detail

parseHeader

public void parseHeader(java.lang.String header)
protected void parseHeader(String header); Extract the initial, condition, and update parts of the For Loop Header

Parameters:
header - - a String that holds the header

getName

public java.lang.String getName()
Get the name of this control construct - for generation of error menus

Overrides:
getName in class ControlModel

getCode

public void getCode(java.util.Vector codeText,
                    OutputStream output)
public void getCode(Vector codeText, OutputStream output) This function generates the code seen by the student

Overrides:
getCode in class ControlModel
Parameters:
codeText - - a vector that holds the code

explainInitial

public ExecutionStatus explainInitial(RunEnv runEnv,
                                      Behavior behavior,
                                      boolean stepFlag,
                                      int lineNumber)
public void explainInitial(Vector explanation, Vector errors, int lineNumber); This function handles explaining any declarations, initializations, or assignments in the for loop header

Parameters:
explanation - - a vector holding the explanation
errors - - a vector holding any errors
lineNumber - - holds the current line number

explainUpdate

public ExecutionStatus explainUpdate(RunEnv runEnv,
                                     Behavior behavior,
                                     int lineNumber)
public void explainUpdate(Vector explanation, Vector errors, int lineNumber); This function handles explaining any update that occurs in the for loop header

Parameters:
explanation - - a vector holding the explanation
errors - - a vector holding any errors
lineNumber - - holds the current line number

explainProcess

public ExecutionStatus explainProcess(RunEnv runEnv,
                                      Behavior behavior,
                                      boolean stepFlag)
public void explainProcess(Vector explanation, OutputStream output, Vector errors) This function generates the explanation of the code for the student.

Overrides:
explainProcess in class ControlModel
Parameters:
explanation - - a vector holding the explanation lines
errors - - a vector holding the error lines
Returns:
status of execution

grade

public static boolean grade(java.lang.String template,
                            java.lang.String code)

main

public static void main(java.lang.String[] args)