Wrote some more comments about the code.

This commit is contained in:
2020-04-29 22:13:34 -05:00
parent 6ba3414367
commit babbdc20af
2 changed files with 17 additions and 5 deletions
+12 -4
View File
@@ -1,8 +1,10 @@
class Expression:
expression = ""
# This object represents all the needed initial data about an expression that is to be parsed.
expression = "" # The formula to parse as a string.
# correct_response = 0
wrong_response = 0
variables = []
wrong_response = 0 # The incorrect response that was entered by the student.
variables = [] # A list of Variable.
def __init__(self, expression_string, variables, wrong_response):
self.expression = expression_string
@@ -10,10 +12,13 @@ class Expression:
self.wrong_response = wrong_response
class Variable:
# This object represents a variable that is found in the formula. It encodes the name, the type of variable
# and the starting point from which to look for mutations in the variable's value.
name = ""
type = ""
starting_point = 0
ending_point = 0
# ending_point = 0
VARIABLE_TYPES = {
"i" : "Interest",
@@ -32,6 +37,9 @@ class Variable:
@staticmethod
def get_variable_type(variable_name):
# Utilitie function to get the variable's type from it's name.
# For example, a variable with 'i' in its name is an Interest type.
# Returns the variable's type as a string or 'Unknown' otherwise.
if not variable_name in Variable.VARIABLE_TYPES:
return "Unknown"
return Variable.VARIABLE_TYPES[variable_name]