org.problets.domain.model.expression.node.operator.arithmetic
Class Arithmetic

java.lang.Object
  extended by org.problets.domain.model.DomainModel
      extended by org.problets.domain.model.expression.node.NodeModel
          extended by org.problets.domain.model.expression.node.operator.Operator
              extended by org.problets.domain.model.expression.node.operator.arithmetic.Arithmetic
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Addition, BaseModulus, Division, Exponentiation, Multiplication, Subtraction

public class Arithmetic
extends Operator

To hold all constants specific to arithmetic operators

Author:
Amruth Kumar

Field Summary
static int TOTAL_OPERATORS
           
 
Fields inherited from class org.problets.domain.model.expression.node.operator.Operator
INCORRECT_OPERAND_COUNT
 
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, IDENTITY, 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
 
Method Summary
 Value evaluate()
          Checks that arithmetic operators are not applied to boolean operands in Java/C#
 void explain(java.util.Vector explanation, java.util.Vector errors)
          If the result is not an error, the operator is not modulus, and one operand is an integer whereas the other is real, add an explanation for coercion.
 Value getCoercedValue(Value leftValue, Value rightValue, java.lang.String result)
          Method does arithmetic conversions so that the result is stored in an object of the correct data type Arithmetic conversions are defined as follows: --If either operand is long double, result is long double.
 void getLocalLearningObjectives(java.util.Vector learnObjVector)
          Overrides Operator.getLocalLearningObjectives().
 java.lang.String getQualifiedLearningObject()
          Method returns the name of the operator, disambiguated enough so that it can be easily credited in the student model.
 
Methods inherited from class org.problets.domain.model.expression.node.operator.Operator
clone, coerceToReal, contentEquals, contentEquals, getArity, getAssociativity, getOperatorType, getPrecedence, getStudentCopy, getSymbol, grade, locateOperator, main, recursiveContentEquals, recursiveSetValue
 
Methods inherited from class org.problets.domain.model.expression.node.NodeModel
classifyNodes, getContent, getLeftChild, getNonRecursiveContent, getOrder, getPosition, getRecursiveContent, getRightChild, getSideEffects, getValue, insertInOrder, setLeftChild, setOrder, setPosition, setRightChild, setValue, shortCircuit, skip, subExpToString, toString, valueEquals
 
Methods inherited from class org.problets.domain.model.DomainModel
getId, getIdName, grade
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOTAL_OPERATORS

public static final int TOTAL_OPERATORS
See Also:
Constant Field Values
Method Detail

getLocalLearningObjectives

public void getLocalLearningObjectives(java.util.Vector learnObjVector)
Overrides Operator.getLocalLearningObjectives(). The answer being correct is a learning objective applicable to all arithmetic operators Coercion is another learning objective that applies to most arithmetic operators This is used by +, -, *

Overrides:
getLocalLearningObjectives in class Operator

getQualifiedLearningObject

public java.lang.String getQualifiedLearningObject()
Method returns the name of the operator, disambiguated enough so that it can be easily credited in the student model.

Overrides:
getQualifiedLearningObject in class Operator

evaluate

public Value evaluate()
Checks that arithmetic operators are not applied to boolean operands in Java/C#

Overrides:
evaluate in class Operator

explain

public void explain(java.util.Vector explanation,
                    java.util.Vector errors)
If the result is not an error, the operator is not modulus, and one operand is an integer whereas the other is real, add an explanation for coercion.

Overrides:
explain in class Operator

getCoercedValue

public Value getCoercedValue(Value leftValue,
                             Value rightValue,
                             java.lang.String result)
Method does arithmetic conversions so that the result is stored in an object of the correct data type Arithmetic conversions are defined as follows: --If either operand is long double, result is long double. --Else, if either operand is double, result is double. --Else, if either operand is float, result is float. --Else, integral promotions are done: char, short, unsigned short are coerced to int --Then, if either operand is unsigned long, result is unsigned long. --A step ignored here --Else, if either operand is long, result is long. --Else, if either operand is unsigned, result is unsigned. --Else, result is an int. Source: http://std.dkuug.dk/jtc1/sc22/wg21/docs/wp/html/oct97/