Exemplo n.º 1
0
 def play(self, domino: Domino) -> bool:
     """
     Add a domino to the current train, updating internal state as necessary.
     :param domino: the Domino to add
     :return: a boolean indicating if the domino was added successfully
     """
     if not domino.contains(self.requires):
         return False
     self.cars.append(domino)
     self.requires = domino.get_other_number(self.requires)
     self.demands_satisfaction = domino.is_double
     return True
Exemplo n.º 2
0
 def test_other(self):
     d = Domino(2, 3)
     self.assertEqual(3, d.get_other_number(2))
     self.assertEqual(2, d.get_other_number(3))
     self.assertIsNone(d.get_other_number(42))