Advertisement
ALEXANDAR_GEORGIEV

sells_table

Jan 4th, 2023 (edited)
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | Source Code | 0 0
  1.  
  2. class Cells:
  3.     def __init__(self):
  4.         self.cells = {}
  5.  
  6.     def setItem(self, r, c, value):
  7.         if r not in self.cells:
  8.             self.cells[r] = {}
  9.         self.cells[r][c] = value
  10.  
  11.     def getItem(self, r, c):
  12.         if r not in self.cells:
  13.             return None
  14.         if c not in self.cells[r]:
  15.             return None
  16.         return self.cells[r][c]
  17.  
  18.     def getNumber(self, r, c):
  19.         v = self.getItem(r, c)
  20.         if v is None:
  21.             return 0
  22.         return v
  23.  
  24.     def getCells(self):
  25.         return self.cells
  26.  
  27.     def setItemErrors(self, r, c, step, value):
  28.         if r not in self.cells:
  29.             self.cells[r] = {}
  30.         if c not in self.cells[r]:
  31.             self.cells[r][c] = {}
  32.         self.cells[r][c][step] = value
  33.  
  34.     def getItemErrors(self, r, c, step):
  35.         if r not in self.cells:
  36.             return None
  37.         if c not in self.cells[r]:
  38.             return None
  39.         if step not in self.cells[r][c]:
  40.             return None
  41.         return self.cells[r][c][step]
  42.  
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement