Пример #1
0
 def __repr__(self):
     """
     Return a string representation of the ship.
     :return: A tuple converted to string. The tuple's content should be (in
     the exact following order):
         1. A list of all the ship's coordinates.
         2. A list of all the ship's hit coordinates.
         3. Last sailing direction.
         4. The size of the board in which the ship is located.
     """
     return str((self.coordinates(), self.__damaged_cells_list,
                 ship_helper.direction_repr_str(Direction,
                                                self.direction()),
                 self.__board_side))
Пример #2
0
 def __repr__(self):
     """
     Return a string representation of the ship.
     :return: A tuple converted to string (that is, for a tuple x return
         str(x)).
     The tuple's content should be (in the exact following order):
         1. A list of all the ship's coordinates.
         2. A list of all the ship's hit coordinates.
         3. Last sailing direction.
         4. The size of the board in which the ship is located.
     """
     direction = sh.direction_repr_str(Direction, self.__ship_direction)
     return str((self.coordinates(), self.damaged_cells(), direction,
                 self.__board_size))
Пример #3
0
    def __repr__(self):
        """
        Return a string representation of the ship.
        :return: A tuple converted to string. The tuple's content should be:
            1. A list of all the ship's coordinates.
            2. A list of all the ship's hit coordinates.
            3. Last sailing direction.
            4. The size of the board in which the ship is located.
        """

        coords = self.coordinates()
        hits = self.damaged_cells()
        dirc = direction_repr_str(Direction, self.__direction)
        size = self.__board_size
        return str((coords, hits, dirc, size))
Пример #4
0
 def __repr__(self):
     """
     Return a string representation of the ship.
     :return: A tuple converted to string (that is, for a tuple x return
         str(x)).
     The tuple's content should be (in the exact following order):
         1. A list of all the ship's coordinates.
         2. A list of all the ship's hit coordinates.
         3. Last sailing direction.
         4. The size of the board in which the ship is located.
     """
     coordinates = copy.deepcopy(self.coordinates())
     damaged_list = copy.deepcopy(self.damaged_cells())
     description = (coordinates, damaged_list, ship_helper.direction_repr_str(Direction,self.__direction), self.__board_size)
     return str(description)
Пример #5
0
 def __repr__(self):
     """
     Return a string representation of the ship.
     :return: A tuple converted to string (that is, for a tuple x return
         str(x)).
     The tuple's content should be (in the exact following order):
         1. A list of all the ship's coordinates.
         2. A list of all the ship's hit coordinates.
         3. Last sailing direction.
         4. The size of the board in which the ship is located.
     """
     represantation = (self.coordinates(),
                       self.generate_coordinates_from_boolean(),
                       sh.direction_repr_str(Direction, self.direction()),
                       self.get_board_size())
     return str(represantation)
    def __repr__(self):

        """
        Return a string representation of the ship.
        :return: A tuple converted to string. The tuple's content should be (in
        the exact following order):
            1. A list of all the ship's coordinates.
            2. A list of all the ship's hit coordinates.
            3. Last sailing direction.
            4. The size of the board in which the ship is located.
        """

        descriptive_tpl = str(tuple((self.coordinates(), self._hits,
                                     ship_helper.direction_repr_str(
                                         Direction, self._act_direction),
                                     self._board_size)))
        return descriptive_tpl
Пример #7
0
 def __repr__(self):
     """
     Return a string representation of the ship.
     :return: A tuple converted to string (that is, for a tuple x return
         str(x)).
     The tuple's content should be (in the exact following order):
         1. A list of all the ship's coordinates.
         2. A list of all the ship's hit coordinates.
         3. Last sailing direction.
         4. The size of the board in which the ship is located.
     """
     cord_list = self._coordinate_list
     hit_cord_list = self._damaged_cell_list
     direction = h.direction_repr_str(Direction, self._direction)
     board_size = self._board_size
     repr_tuple = cord_list, hit_cord_list, direction, board_size
     return str(repr_tuple)
Пример #8
0
    def __repr__(self):
        """
        Return a string representation of the ship.
        :return: A tuple converted to string (that is, for a tuple x return
            str(x)).
        The tuple's content should be (in the exact following order):
            1. A list of all the ship's coordinates.
            2. A list of all the ship's hit coordinates.
            3. Last sailing direction.
            4. The size of the board in which the ship is located.
        """

        # Gets all coordinates of ship in a list
        ship_coordinates = self.__ship_coordinates
        # Gets all damaged ship coordinates
        damaged_coordinates = self.damaged_cells()
        # Gets string value of last direction
        last_direction = sh.direction_repr_str(Direction, self.direction())
        # Make the duple needed
        represent = (ship_coordinates, damaged_coordinates, last_direction,
                     self.__board_size)
        # Return after converting to str!
        return str(represent)