Implemented __repr__ and __len__ for BasicRegister.
This commit is contained in:
parent
f2ee4cd709
commit
75f7dba546
|
@ -10,12 +10,17 @@ class BasicRegister:
|
|||
"""
|
||||
|
||||
def __init__(self, memory: list[bool]):
|
||||
"""Constructor method"""
|
||||
self.memory: deque[bool] = deque(memory)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"Memory: {[int(value) for value in self.memory]}"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"Memory: {[int(value) for value in self.memory]}"
|
||||
|
||||
def __len__(self) -> int:
|
||||
return len(self.memory)
|
||||
|
||||
def adjusted_by_size(self, resulting_size: int) -> Self:
|
||||
"""
|
||||
Adjusts a register to a given size.
|
||||
|
@ -72,8 +77,8 @@ def binary_sum(a_original: BasicRegister, b_original: BasicRegister) -> BasicReg
|
|||
:return: Register containing the sum.
|
||||
:rtype: BasicRegister
|
||||
"""
|
||||
size_a = len(a_original.memory)
|
||||
size_b = len(b_original.memory)
|
||||
size_a = len(a_original)
|
||||
size_b = len(b_original)
|
||||
|
||||
required_size = max(size_a, size_b)
|
||||
|
||||
|
|
Loading…
Reference in New Issue