remove redundant method: BasicRegister.compact_str()

This commit is contained in:
dymik739 2023-06-28 12:59:25 +03:00
parent 4e0e30383d
commit 9e06a93c19
2 changed files with 4 additions and 10 deletions

View File

@ -22,9 +22,6 @@ class BasicRegister:
def __len__(self) -> int:
return len(self.memory)
def compact_str(self) -> str:
return "".join([str(int(value)) for value in self.memory])
def adjusted_by_size(self, resulting_size: int) -> Self:
"""
Adjusts a register to a given size.
@ -93,9 +90,6 @@ class Counter:
def __len__(self) -> int:
return len(self.memory)
def compact_str(self) -> str:
return "".join([str(int(value)) for value in self.memory])
def decrement(self):
self.memory = binary_subtraction(self, BasicRegister([False] * (len(self.memory) - 1) + [True])).memory

View File

@ -19,16 +19,16 @@ def input_handler(first_register: bu.BasicRegister, second_register: bu.BasicReg
match input("Choose method to use (1-4):\n>>> "):
case "1":
result, data_table = bu.binary_multiplication_method_1(first_register, second_register)
print(f"Multiplication:\n{bu.format_device_state_table(data_table)}\nResult: {result.compact_str()}")
print(f"Multiplication:\n{bu.format_device_state_table(data_table)}\nResult: {result}")
case "2":
result, data_table = bu.binary_multiplication_method_2(first_register, second_register)
print(f"Multiplication:\n{bu.format_device_state_table(data_table)}\nResult: {result.compact_str()}")
print(f"Multiplication:\n{bu.format_device_state_table(data_table)}\nResult: {result}")
case "3":
result, data_table = bu.binary_multiplication_method_3(first_register, second_register)
print(f"Multiplication:\n{bu.format_device_state_table(data_table)}\nResult: {result.compact_str()}")
print(f"Multiplication:\n{bu.format_device_state_table(data_table)}\nResult: {result}")
case "4":
result, data_table = bu.binary_multiplication_method_4(first_register, second_register)
print(f"Multiplication:\n{bu.format_device_state_table(data_table)}\nResult: {result.compact_str()}")
print(f"Multiplication:\n{bu.format_device_state_table(data_table)}\nResult: {result}")
case _:
print("Such method does not exist, try again.")
case "d":