|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.problets.domain.model.control.iteration.InfiniteLoopModel
public class InfiniteLoopModel
Class: InfiniteLoopModel Author: Greg Tomalesky Purpose: This class handles creating an explanation for an infinite loop based on six different types of relational operators: >, <, >=, <=, ==, != Each type of relational operator will have sub-divisions based on how a condition is always true. >, >= : - variable always increases in value relative to the value its being compared to - variable increases the same or greater amount than the valued being compared to does - variable stays the same relative to the value <, <= : - variable always decreases in value relative to the value being compared to - variable decreases the same or greater amount than the valued being compared to - variable stays the same relative to the value != : - variable moves away from the value being compared to - variable skips over value when incremented or decremented - variable moves the same amount or more than the value being compared to does - variable stays the same relative to the value == : - variable moves the same amount that the value being compared to does - variable stays the same relative to the value NOTE: Currently, this class does not handle cases where values are increasing geometrically or linearly
Constructor Summary | |
---|---|
InfiniteLoopModel()
|
Method Summary | |
---|---|
static double |
calculateChange(java.util.Vector valueVector,
int iterations)
public static double calculateChange(Vector valueVector, int iterations); This function will calculate the current amount by which either the condition or boundary value will change at the present iteration of the infinite loop. |
static java.util.Vector |
explain(java.util.Vector conditionVector,
java.util.Vector terminalVector,
java.lang.String condition,
Expression condition_exp)
public static void explain(Vector condVector, Vector boundVector, String operator, Vector explanation); Generate an explanation for while an infinite loop is being terminated |
static java.lang.String |
explainSkip(java.util.Vector condVector,
java.util.Vector boundVector,
java.lang.String leftSideName,
java.lang.String rightSideName)
private String explainSkip(Vector condVector, Vector boundVector); This function handles explaining any cases whereby the condition or bounds skips across the other. |
static void |
main(java.lang.String[] args)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public InfiniteLoopModel()
Method Detail |
---|
public static double calculateChange(java.util.Vector valueVector, int iterations)
valueVector
- - a vector that holds Valuesiterations
- - the current iteration of the simulated loop
public static java.lang.String explainSkip(java.util.Vector condVector, java.util.Vector boundVector, java.lang.String leftSideName, java.lang.String rightSideName)
condVector
- - a vector that holds values of the lhs
in a conditionboundVector
- - a vector that holds values of the rhs
in a condition
public static java.util.Vector explain(java.util.Vector conditionVector, java.util.Vector terminalVector, java.lang.String condition, Expression condition_exp)
condVector
- - a vector that holds values of a variable
in a conditionboundVector
- - a vector that holds values of the value that
is being compared toexplanation
- - a Vector holding the generated explanationscondition
- - a string holding the template for the conditioncondition
- - a string that holds the condition templatecondition_exp
- - an expression object representing
the condition of a looppublic static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |