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


Python Game.score方法代码示例

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


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

示例1: GameTest

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [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: TestGame

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
class TestGame(unittest.TestCase):
    game = None
    def setUp(self):
        self.game = Game()
    def tearDown(self):
        self.game = None
    def testOneThrow(self):
        self.game.add(1)
        self.assertEqual(1, self.game.score())
    def testTwoThrowsNoMark(self):
        self.game.add(1)
        self.game.add(1)
        self.assertEqual(2, self.game.score())
    def testFourFramesNoMark(self):
        self.game.add(1)
        self.game.add(1)
        self.game.add(1)
        self.game.add(1)
        self.assertEqual(4, self.game.score())
开发者ID:khardi,项目名称:bowling,代码行数:21,代码来源:TestGame.py

示例3: assertScoreForRolls

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [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

示例4: score_full_game

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
 def score_full_game(self, balls):
     game = Game()
     for ball in balls:
         game.add_ball(ball)
     return game.score()
开发者ID:MariusCC,项目名称:examples,代码行数:7,代码来源:test.py

示例5: check_full_game

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
 def check_full_game(self, expectedScore, balls):
     game = Game()
     for ball in balls:
         game.add_ball(ball)
     self.assertEquals(expectedScore, game.score())
开发者ID:MariusCC,项目名称:examples,代码行数:7,代码来源:test.py

示例6: test_strike

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
 def test_strike(self):
     game = Game()
     game.add_ball(10)
     self.assertEquals(game.score(), 10)
     self.assertEquals(game.current_frame(), 2)
开发者ID:MariusCC,项目名称:examples,代码行数:7,代码来源:test.py

示例7: test_add_second_ball

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
 def test_add_second_ball(self):
     game = Game()
     game.add_ball(1)
     game.add_ball(2)
     self.assertEquals(game.score(), 3)
     self.assertEquals(game.current_frame(), 2)
开发者ID:MariusCC,项目名称:examples,代码行数:8,代码来源:test.py

示例8: test_add_ball

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
 def test_add_ball(self):
     game = Game()
     game.add_ball(1)
     self.assertEquals(game.current_frame(), 1)
     self.assertEquals(game.score(), 1)
开发者ID:MariusCC,项目名称:examples,代码行数:7,代码来源:test.py

示例9: test_game_init

# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import score [as 别名]
 def test_game_init(self):
     game = Game()
     self.assertEquals(game.current_frame(), 1)
     self.assertEquals(game.score(), 0)
开发者ID:MariusCC,项目名称:examples,代码行数:6,代码来源:test.py


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