当前位置: 首页>>代码示例>>Python>>正文


Python Board.setValue方法代码示例

本文整理汇总了Python中Board.setValue方法的典型用法代码示例。如果您正苦于以下问题:Python Board.setValue方法的具体用法?Python Board.setValue怎么用?Python Board.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Board的用法示例。


在下文中一共展示了Board.setValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestValidationFunctions

# 需要导入模块: import Board [as 别名]
# 或者: from Board import setValue [as 别名]
class TestValidationFunctions(unittest.TestCase):


    def setUp(self):
        self.board=Board()
        #fill the board with values that will
        #make for both valid and invalid situations
        self.board.setValue(0,0,4)
        self.board.setValue(4,0,7)
        self.board.setValue(0,1,5)

    def test_horizontal1(self):
        self.assertTrue(self.board.horizontal_validation(0,6))

    def test_horizontal2(self):
        self.assertFalse(self.board.horizontal_validation(0,4))

    def test_vertical1(self):
        self.assertTrue(self.board.vertical_validation(0,9))

    def test_vertical2(self):
        self.assertFalse(self.board.vertical_validation(0,7))

    def test_block1(self):
        self.assertTrue(self.board.block_validation(2,2,7))

    def test_block2(self):
        self.assertFalse(self.board.block_validation(2,2,5))

    def test_validation1(self):
        self.assertTrue(self.board.validate(2,2,8))

    def test_validation2(self):
        self.assertFalse(self.board.validate(7,0,7))
开发者ID:jdw6359,项目名称:Sudoku,代码行数:36,代码来源:TestValidationFunctions.py

示例2: read

# 需要导入模块: import Board [as 别名]
# 或者: from Board import setValue [as 别名]
 def read(self, config_file):
     config=open("ConfigFiles/"+config_file)
     board=Board()
     row=0
     col=0
     for line in config:
         for item in line:
             if item !="\n":
                 if item != ".":
                     board.setValue(row,col,int(item))
                 col+=1
         row+=1
         col=0
     return board
开发者ID:jdw6359,项目名称:Sudoku,代码行数:16,代码来源:FileCom.py

示例3: TestValidationFunctions

# 需要导入模块: import Board [as 别名]
# 或者: from Board import setValue [as 别名]
class TestValidationFunctions(unittest.TestCase):


    def setUp(self):
        self.board=Board()
        #fill the board with values that will
        #make for both valid and invalid situations
        self.board.setValue(0,0,4)
        self.board.setValue(0,1,5)

    def test_horizontal1(self):
        self.assertTrue(self.board.horizontal_validation(0,6))

    def test_horizontal2(self):
        self.assertFalse(self.board.horizontal_validation(0,4))
开发者ID:jdw6359,项目名称:Sudoku,代码行数:17,代码来源:TestValidationFuncitons.py

示例4: TestBasicFunctions

# 需要导入模块: import Board [as 别名]
# 或者: from Board import setValue [as 别名]
class TestBasicFunctions(unittest.TestCase):

    # creates an empty board
    def setUp(self):
        self.board = Board()

    # Ensures each slot in a fresh grid is occupied with None
    def test_clear(self):
        for row in range(9):
            for col in range(9):
                self.assertEqual(None, self.board.grid[row][col])

    # Ensures that a value is added to a specific row,col
    def test_add1(self):
        self.board.setValue(1, 1, 4)
        self.assertEqual(4, self.board.grid[1][1])

    # Ensures that a value is added to a specific row,col
    def test_add2(self):
        self.board.setValue(7, 5, 4)
        self.assertEqual(4, self.board.grid[7][5])

    # Ensures that an added value is removed from the specific row,col
    def test_remove1(self):
        self.board.setValue(1, 1, 4)
        self.assertEqual(4, self.board.grid[1][1])
        # will remove and assert None
        self.board.removeValue(1, 1)
        self.assertEqual(None, self.board.grid[1][1])

    # Ensures that an added value is removed from the specific row,col
    def test_remove2(self):
        self.board.setValue(7, 5, 4)
        self.assertEqual(4, self.board.grid[7][5])
        # will remove and assert None
        self.board.removeValue(7, 5)
        self.assertEqual(None, self.board.grid[7][5])
开发者ID:jdw6359,项目名称:Sudoku,代码行数:39,代码来源:TestBasicFunctions.py


注:本文中的Board.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。