the-honk/school/a-level/Y12 2022-2024/Logic/Framework.py

30 lines
No EOL
620 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from __future__ import annotations
from enum import Enum
class Gate(Enum):
AND = '^'
OR = ''
XOR = ''
NAND = ''
NOR = ''
XNOR = ''
class Symbol():
def __init__(self, symbol, initialValue):
self._symbol = symbol
self._value = initialValue
self._tree = []
def setValue(self, newValue):
self._value = newValue
return self
def AND(self, symbol: Symbol):
self._tree.append((Gate.AND, symbol))
return self
def compute():
def __str__(self):
return self._symbol