Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
git first project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mahdi Amini
git first project
Commits
31b767a9
Commit
31b767a9
authored
Feb 25, 2026
by
Mahdi Amini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kffkfk
parent
16d7f5b2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
35 deletions
+28
-35
test33.py
test33.py
+28
-35
No files found.
test33.py
View file @
31b767a9
...
@@ -22,48 +22,41 @@ class Library:
...
@@ -22,48 +22,41 @@ class Library:
"book"
:
book
,
"book"
:
book
,
"count"
:
count
"count"
:
count
}
}
def
__str__
(
self
):
return
self
.
title
def
borrow_book
(
self
,
book
):
if
book
.
book_id
in
self
.
books
and
self
.
books
[
book
.
book_id
][
"count"
]
>
0
:
self
.
books
[
book
.
book_id
][
"count"
]
-=
1
return
True
return
False
def
return_book
(
self
,
book
):
if
book
.
book_id
in
self
.
books
:
self
.
books
[
book
.
book_id
][
"count"
]
+=
1
def
__str__
(
self
):
return
self
.
title
class
Student
:
class
Student
:
def
__init__
(
self
,
student_id
,
full_name
):
def
__init__
(
self
,
student_id
,
full_name
):
self
.
student_id
=
student_id
self
.
student_id
=
student_id
self
.
full_name
=
full_name
self
.
full_name
=
full_name
self
.
current_book
=
None
self
.
current_library
=
None
def
__str__
(
self
):
def
borrow
(
self
,
book
,
library
):
return
self
.
full_name
# ...
class
Borrow
:
def
__init__
(
self
,
student
,
book
,
library
):
self
.
student
=
student
self
.
book
=
book
self
.
library
=
library
def
info
(
self
):
if
self
.
current_book
:
return
f
"{self.student} کتاب «{self.book}» را از کتابخانه {self.library} گرفته است"
self
.
current_library
.
return_book
(
self
.
current_book
)
print
(
f
"{self.full_name} کتاب قبلی را پس داد."
)
book1
=
Book
(
1
,
"رازآلوده"
,
"نویسنده حسین"
)
if
library
.
borrow_book
(
book
):
book2
=
Book
(
2
,
"test"
,
"author test"
)
self
.
current_book
=
book
self
.
current_library
=
library
print
(
f
"{self.full_name} کتاب «{book}» را گرفت."
)
library1
=
Library
(
1
,
"تاریخی"
)
else
:
library2
=
Library
(
2
,
"ورزشی"
)
print
(
"کتاب موجود نیست!"
)
library1
.
add_book
(
book1
,
3
)
library2
.
add_book
(
book2
,
1
)
student1
=
Student
(
1
,
"Ali"
)
borrow1
=
Borrow
(
student1
,
book1
,
library1
)
print
(
borrow1
.
info
())
def
__str__
(
self
):
return
self
.
full_name
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment