Answer:
Kindly check the code screenshot in the attached images below.
Explanation:
Program Files
filename: board.py
from typing import Iterable, List, TypeVar, Any
class Board:
def __init__(self, name:str, row:int, column:int, char:str):
self.name = name
self.row = row
self.column = column
self.char = char
def print_board(self, name:str, row:int, column:int, char:int):
name = name.strip()
print(name)
rowPrint = []
for i in range(int(column)+1):
if i == 0:
colTitle = ' '
else:
colTitle = colTitle + ' ' + str(i-1)
print(colTitle)
for i in range(int(row)):
rowPrint.append(str(i) + (' ' + str(char.strip())) * column)
print(rowPrint[i])
return rowPrint, colTitle
def erase_board(self, name:str, row:int, char:str, erase_row:int, erase_col:int, rowPrint:list, colTitle:list) -> list:
print(name)
print(colTitle)
for i in range(int(row)):
if i == erase_row:
newString = rowPrint[i][:((int(erase_col)+1)*2)] + str(char.strip()) + rowPrint[i][((int(erase_col)+1)*2)+1:]
rowPrint[i]=newString
print(rowPrint[i])
else:
print(rowPrint[i])
return rowPrint
def fill_board(self, name:str, row:int, fill_char:str, fill_row:int, fill_col:int, rowPrint:list, colTitle:list)->list:
print(name)
print(colTitle)
for i in range(int(row)):
if i == fill_row:
newFillString = rowPrint[i][:((int(fill_col)+1)*2)] + str(fill_char.strip()) + rowPrint[i][((int(fill_col)+1)*2)+1:]
rowPrint[i]= newFillString
print(rowPrint[i])
else:
print(rowPrint[i])
return rowPrint
def switch_action(self, name:str, colTitle:list, rowPrint:list)->None:
print(name)
print(colTitle)
for i in rowPrint:
print(i)
def new_board_save(self, row:int, column:int, char:str)->list:
rowPrint = []
for i in range(int(column) + 1):
if i == 0:
colTitle = ' '
else:
colTitle = colTitle + ' ' + str(i - 1)
for i in range(int(row)):
rowPrint.append(str(i) + (' ' + str(char)) * column)
return rowPrint, colTitle