19 lines
793 B
Python
19 lines
793 B
Python
import math
|
|
import re
|
|
|
|
|
|
class Game:
|
|
def __init__(self, board_game_id, name, genre, publisher, price, count = None, discount = None):
|
|
self.board_game_id = board_game_id
|
|
self.name = name
|
|
self.genre = genre
|
|
self.publisher = publisher
|
|
self.price = price
|
|
self.count = count
|
|
self.discount = discount
|
|
|
|
def __str__(self):
|
|
cleaned_string = self.price.replace("\u202f", "")[:-2]
|
|
cleaned_string = cleaned_string.replace(",", ".")
|
|
return f"{self.name}\nЖанр: {self.genre}\nИздатель: {self.publisher}\n" + (str(self.price) if self.discount is None else f"{math.ceil(float(cleaned_string) * (100 - self.discount) / 100)} ₽ -{self.discount}%") + (f"\n{self.count} шт." if self.count is not None else "")
|