-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathop_not.py
More file actions
27 lines (21 loc) · 848 Bytes
/
op_not.py
File metadata and controls
27 lines (21 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# NOT CLASS
# Stores a single operator to be NOT'd
from op import *
class op_not(op):
# Init function - Stores data pertaining to the class
def __init__(self, *argv):
super(op_not, self).__init__(*argv)
# Returns the type of this operator
def getType(self):
return "not"
# Calculates the value of this operator given a dictionary of variable values
def calcValue(self, args):
return -self.getOperand(0).calcValue(args)+1
# Used to see if 2 AND statements are the same. Ignores operand order
def __eq__(self, other):
if other == None: return False
if other.getType() != "not": return False
return self.getOperand(0) == other.getOperand(0)
# Used to print this class out nicely
def __str__(self):
return "[NOT: {}]".format(str(self.getOperand(0)))