本文整理汇总了Python中ship.Ship.set_size方法的典型用法代码示例。如果您正苦于以下问题:Python Ship.set_size方法的具体用法?Python Ship.set_size怎么用?Python Ship.set_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ship.Ship
的用法示例。
在下文中一共展示了Ship.set_size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestShip
# 需要导入模块: from ship import Ship [as 别名]
# 或者: from ship.Ship import set_size [as 别名]
class TestShip(unittest.TestCase):
def setUp(self):
self.ship = Ship((0,0), 5, 0, [Point(0, (x, 0)) for x in range(5)])
def test_get_points(self):
self.assertEqual(self.ship.get_points(), [Point(0, (x,0)) for x in range(5)])
def test_set_points(self):
self.assertEqual(self.ship.set_points([Point(0, (x,0)) for x in range(5,10)]), True)
self.assertEqual(self.ship.get_points(), [Point(0, (x,0)) for x in range(5,10)])
def test_get_hits(self):
self.assertEqual(self.ship.get_hits(), [0] * self.ship.get_size())
def test_set_hits(self):
self.assertEqual(self.ship.set_hits([1] * self.ship.get_size()), True)
self.assertEqual(self.ship.get_hits(), [1] * self.ship.get_size())
def test_get_orientation(self):
self.assertEqual(self.ship.get_orientation(), 0)
def test_set_orientation(self):
self.assertEqual(self.ship.set_orientation(1), True)
self.assertEqual(self.ship.get_orientation(), 1)
def test_get_size(self):
self.assertEqual(self.ship.get_size(), 5)
def test_set_size(self):
self.assertEqual(self.ship.set_size(2), True)
self.assertEqual(self.ship.get_size(), 2)
def test_get_start(self):
self.assertEqual(self.ship.get_start(), (0,0))
def test_set_start(self):
self.assertEqual(self.ship.set_start((1,1)), True)
self.assertEqual(self.ship.get_start(), (1,1))
def test_is_hit(self):
self.assertEqual(self.ship.is_hit(Point(0, (0,0))), True)
self.assertEqual(self.ship.is_hit(Point(0, (100, 100))), False)
def test_is_sunk(self):
self.assertEqual(self.ship.is_sunk(), False)
self.ship.set_hits([1] * self.ship.get_size())
self.assertEqual(self.ship.is_sunk(), True)
def test_string(self):
self.assertEqual(str(self.ship), "[0 0 0 0 0 ]")