Ejemplo n.º 1
0
 def __init__(self,
              producer='def_producer',
              price_in_uah=0,
              brand=Brand(4),
              colour=Colour(1),
              warranty_in_days=0,
              weight_in_grams=0,
              length_in_cm=0):
     super().__init__(producer, price_in_uah, brand, colour,
                      warranty_in_days, weight_in_grams)
     self.length_in_cm = length_in_cm
Ejemplo n.º 2
0
 def __init__(self,
              producer='def_producer',
              price_in_uah=0,
              brand=Brand(4),
              colour=Colour(8),
              warranty_in_days=0,
              weight_in_grams=0):
     self.producer = producer
     self.price_in_uah = price_in_uah
     self.brand = brand
     self.colour = colour
     self.warranty_in_days = warranty_in_days
     self.weight_in_grams = weight_in_grams
Ejemplo n.º 3
0
    @staticmethod
    def sort_by_weight_in_grams(input_tool_list, input_sort_type):
        """
        Testing sorter by weight in grams
        >>> test_ruler_list = [test_ruler1, test_ruler2, test_ruler3]
        >>> OfficeToolManagerUtils.sort_by_weight_in_grams(test_ruler_list, SortType(2))
        >>> print(test_ruler_list[0].weight_in_grams)
        31
        >>> print(test_ruler_list[2].weight_in_grams)
        20
        """
        if input_sort_type == SortType(1):
            input_tool_list.sort(
                key=lambda tool_to_sort: tool_to_sort.weight_in_grams)
        elif input_sort_type == SortType(2):
            input_tool_list.sort(
                key=lambda tool_to_sort: tool_to_sort.weight_in_grams,
                reverse=True)
        else:
            print("cant be sorted by weight in grams")


if __name__ == '__main__':
    import doctest

    test_ruler1 = Ruler("Ukraine", 110, Brand.axent, Colour(1), 210, 20, 20)
    test_ruler2 = Ruler("Germany", 200, Brand.buromax, Colour(3), 330, 30, 30)
    test_ruler3 = Ruler("Poland", 80, Brand.levenhuk, Colour(1), 120, 31, 10)
    doctest.testmod(verbose=True)