Commit f79138fa authored by Mahdi Amini's avatar Mahdi Amini

Delete test33.py

parent 16d7f5b2
class Book:
def __init__(self, book_id, title, author):
self.book_id = book_id
self.title = title
self.author = author
def __str__(self):
return f"{self.title} - {self.author}"
class Library:
def __init__(self, library_id, title):
self.library_id = library_id
self.title = title
self.books = {}
def add_book(self, book, count):
if book.book_id in self.books:
self.books[book.book_id]["count"] += count
else:
self.books[book.book_id] = {
"book": book,
"count": count
}
def __str__(self):
return self.title
class Student:
def __init__(self, student_id, full_name):
self.student_id = student_id
self.full_name = full_name
def __str__(self):
return self.full_name
# ...
class Borrow:
def __init__(self, student, book, library):
self.student = student
self.book = book
self.library = library
def info(self):
return f"{self.student} کتاب «{self.book}» را از کتابخانه {self.library} گرفته است"
book1 = Book(1, "رازآلوده", "نویسنده حسین")
book2 = Book(2, "test", "author test")
library1 = Library(1, "تاریخی")
library2 = Library(2, "ورزشی")
library1.add_book(book1, 3)
library2.add_book(book2, 1)
student1 = Student(1, "Ali")
borrow1 = Borrow(student1, book1, library1)
print(borrow1.info())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment