Advertisement
Nenogzar

01_rhombus_of_stars_1

Jul 3rd, 2024
535
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.86 KB | None | 0 0
  1. """ 1 """
  2.  
  3. n = int(input())
  4.  
  5.  
  6. def print_row(size, row):
  7.     empty = " "
  8.     star = "* "
  9.     print(f"{empty * (size - row)}{star * row}")
  10.  
  11.  
  12. def print_upper_part(size):
  13.     for row in range(1, size):
  14.         print_row(size, row)
  15.  
  16.  
  17. def print_center_part(size):
  18.     print_row(size, size)
  19.  
  20.  
  21. def print_bottom_part(size):
  22.     for row in range(size - 1, 0, -1):
  23.         print_row(size, row)
  24.  
  25.  
  26. def print_rhumbus(size):
  27.     print_upper_part(size)
  28.     print_center_part(size)
  29.     print_bottom_part(size)
  30.  
  31.  
  32. print_rhumbus(n)
  33.  
  34. """ 2 """
  35.  
  36.  
  37. class InputData:
  38.     def __init__(self) -> None:
  39.         self.n: int = int(input())
  40.  
  41.  
  42. class PrintRow:
  43.     def print_row(self, size: int, row: int) -> None:
  44.         empty: str = " "
  45.         star: str = "* "
  46.         print(f"{empty * (size - row)}{star * row}")
  47.  
  48.  
  49. class RhombusParts:
  50.     def __init__(self, *data) -> None:
  51.         [self.size,
  52.          self.print_row_obj] = data
  53.  
  54.     def print_upper_part(self) -> None:
  55.         for row in range(1, self.size):
  56.             self.print_row_obj.print_row(self.size, row)
  57.  
  58.     def print_center_part(self) -> None:
  59.         self.print_row_obj.print_row(self.size, self.size)
  60.  
  61.     def print_bottom_part(self) -> None:
  62.         for row in range(self.size - 1, 0, -1):
  63.             self.print_row_obj.print_row(self.size, row)
  64.  
  65.  
  66. class RhombusPrinter:
  67.     def __init__(self, size: int) -> None:
  68.         self.size: int = size
  69.         self.print_row_obj: PrintRow = PrintRow()
  70.         self.rhombus_parts: RhombusParts = RhombusParts(size, self.print_row_obj)
  71.  
  72.     def print_rhombus(self) -> None:
  73.         self.rhombus_parts.print_upper_part()
  74.         self.rhombus_parts.print_center_part()
  75.         self.rhombus_parts.print_bottom_part()
  76.  
  77.  
  78. input_data: InputData = InputData()
  79. rhombus_printer: RhombusPrinter = RhombusPrinter(input_data.n)
  80. rhombus_printer.print_rhombus()
  81.  
Advertisement
Comments
  • go6odn28
    173 days
    # Python 1.08 KB | 0 0
    1. class InputData:
    2.     def __init__(self) -> None:
    3.         self.n: int = int(input())
    4.  
    5.  
    6. class PrintRow:
    7.     def print_row(self, size: int, row: int) -> None:
    8.         empty: str = " "
    9.         star: str = "* "
    10.         print(f"{empty * (size - row)}{star * row}")
    11.  
    12.  
    13. class RhombusPrinter:
    14.     def __init__(self, size: int) -> None:
    15.         self.size: int = size
    16.         self.print_row_obj: PrintRow = PrintRow()
    17.  
    18.     def print_rhombus(self) -> None:
    19.         self._print_upper_part()
    20.         self._print_center_part()
    21.         self._print_bottom_part()
    22.  
    23.     def _print_upper_part(self) -> None:
    24.         for row in range(1, self.size):
    25.             self.print_row_obj.print_row(self.size, row)
    26.  
    27.     def _print_center_part(self) -> None:
    28.         self.print_row_obj.print_row(self.size, self.size)
    29.  
    30.     def _print_bottom_part(self) -> None:
    31.         for row in range(self.size - 1, 0, -1):
    32.             self.print_row_obj.print_row(self.size, row)
    33.  
    34.  
    35. input_data: InputData = InputData()
    36. rhombus_printer: RhombusPrinter = RhombusPrinter(input_data.n)
    37. rhombus_printer.print_rhombus()
Add Comment
Please, Sign In to add comment
Advertisement