From a6b0eb17e7c7f88d890f8d5a03b68e47aec78391 Mon Sep 17 00:00:00 2001 From: starnakin Date: Tue, 6 Aug 2024 13:12:55 +0200 Subject: [PATCH] add: reading date and release date --- Book.py | 6 +++++- constructor_example.json | 4 +++- main.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Book.py b/Book.py index a800199..7721d40 100644 --- a/Book.py +++ b/Book.py @@ -1,10 +1,12 @@ class Book: - def __init__(self, name: str, description: str, image: str, review: str) -> None: + def __init__(self, name: str, description: str, image: str, review: str, release_date: str, reading_date: str) -> None: self.name: str = name self.description: str = description self.image: str = image self.review: str = review + self.release_date: str = release_date + self.reading_date: str = reading_date def to_html(self) -> str: return f""" @@ -13,7 +15,9 @@ class Book:

{self.name}

{self.description}

+

{self.release_date}

{self.review} + {self.reading_date} """ \ No newline at end of file diff --git a/constructor_example.json b/constructor_example.json index 51b7a86..4759e22 100644 --- a/constructor_example.json +++ b/constructor_example.json @@ -4,7 +4,9 @@ "name": "1984", "description": "1984 est un roman dystopique de l'écrivain britannique George Orwell. Publié le 8 juin 1949 par Secker & Warburg, il s'agit du neuvième et dernier livre d'Orwell achevé de son vivant", "image": "1984.jpg", - "review": "ct pas mal" + "review": "ct pas mal", + "reading_date": "08/2024", + "release_date": "08/06/1949" } ] } \ No newline at end of file diff --git a/main.py b/main.py index ec3e886..aa53422 100644 --- a/main.py +++ b/main.py @@ -15,7 +15,7 @@ books = data['books'] html = "" for book_data in books: - book = Book(book_data["name"], book_data["description"], book_data["image"], book_data["review"]) + book = Book(book_data["name"], book_data["description"], book_data["image"], book_data["review"], book_data["release_date"], book_data["reading_date"]) html += book.to_html() f = open("cast.html")