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


Python Game.roll方法代码示例

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


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

示例1: GameTest

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
class GameTest(unittest2.TestCase):
  def setUp(self):
    self.game = Game()

  def testGutterGame(self):
    self.rollForMe(0)
    self.assertEqual(self.game.score(), 0)

  def testAllOnes(self):
    self.rollForMe(1)
    self.assertEqual(self.game.score(), 20)

  def testPerfectGame(self):
    self.rollForMe(10, 12)
    self.assertEqual(self.game.score(), 300)

  def testSpare(self):
    self.rollForMe(5, 2)
    self.rollForMe(2, 1)
    self.rollForMe(0, 17)
    self.assertEqual(self.game.score(), 14)

  def rollForMe(self, pins, times=20):
    for element in range(times):
      self.game.roll(pins)
开发者ID:viniciustelesbezerra,项目名称:bowlinggame,代码行数:27,代码来源:test_game.py

示例2: test_calculates_for_strike

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
 def test_calculates_for_strike(self):
     game = Game()  
     game.roll(10)
     game.roll(5)
     game.roll(4)
     
     self.assertEqual(28, game.score)
开发者ID:michali,项目名称:Python-Katas,代码行数:9,代码来源:GameTests.py

示例3: test_calculates_for_spare

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
 def test_calculates_for_spare(self):
     game = Game()    
     game.roll(5)
     game.roll(5)
     game.roll(3)
     
     self.assertEqual(16, game.score)
开发者ID:michali,项目名称:Python-Katas,代码行数:9,代码来源:GameTests.py

示例4: test_calculates_score_no_spare_no_strike

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
 def test_calculates_score_no_spare_no_strike(self):
     game = Game()
     noOfStruckPins = 5
     
     game.roll(noOfStruckPins)
     
     self.assertEqual(game.score, noOfStruckPins)
开发者ID:michali,项目名称:Python-Katas,代码行数:9,代码来源:GameTests.py

示例5: assertScoreForRolls

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
    def assertScoreForRolls(self, rolls, expectedScore, msg = None):
        theGame = Game()

        for roll in rolls:
            theGame.roll(roll)

        theActualScore = theGame.score()

        if theActualScore != expectedScore:
            print 'expected score: %d, but got score: %d' % ( expectedScore, theActualScore )
开发者ID:shyela,项目名称:bowling-python,代码行数:12,代码来源:TestGame.py

示例6: test_strike_on_last_frame

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
    def test_strike_on_last_frame(self):
        game = Game()
        game.roll(0)
        game.roll(0)
        
        game.roll(0)
        game.roll(0)
        
        game.roll(0)
        game.roll(0)
        
        game.roll(0)
        game.roll(0)
        
        game.roll(0)
        game.roll(0)

        game.roll(0)
        game.roll(0)

        game.roll(0)
        game.roll(0)

        game.roll(0)
        game.roll(0)
        
        game.roll(0)
        game.roll(0)
        
        game.roll(10)
        
        game.roll(1)           
        game.roll(1)
        
        self.assertEqual(12, game.score)
开发者ID:michali,项目名称:Python-Katas,代码行数:37,代码来源:GameTests.py

示例7: test_spare_on_last_frame

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import roll [as 别名]
    def test_spare_on_last_frame(self):
        game = Game()
        game.roll(0)
        game.roll(0)
        
        game.roll(0)
        game.roll(0)
        
        game.roll(0)
        game.roll(0)
        
        game.roll(0)
        game.roll(0)
        
        game.roll(0)
        game.roll(0)

        game.roll(0)
        game.roll(0)

        game.roll(0)
        game.roll(0)

        game.roll(0)
        game.roll(0)
        
        game.roll(0)
        game.roll(0)
        
        game.roll(5)
        game.roll(5)   
        
        game.roll(1)
        
        self.assertEqual(11, game.score)
开发者ID:michali,项目名称:Python-Katas,代码行数:37,代码来源:GameTests.py


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