مشروع إدارة المكتبة ، هل كودي صحيح؟

بسم الله الرحمن الرحيم
أولا: عيد مبارك وتقبل الله منا ومنكم صالح الاعمال

ثانيا: مشروع إدارة المكتبة ممتع جدا خصوصا لما عرفت طرقة الدوال صار التفكير باي مشروع سهل جدا لكن ،،،، وجدت فرق بين حلي للكود وحل الأستاذ عادل حفظه الله
حيث اني قسمت البرنامج الى 8 دوال

فحبيت أسأل هل حلي صحيح او اتدرب على حل الأستاذ عادل

# عمل برنامج اعارة كتب
# 1- عمل قاموس فاضي 
# 2- عمل دالة لمسح الشاشة
# 3- عمل دالة لعرض القائمة  
# 4- عمل دالة لإضافة كتاب
# 5- عمل دالة لإستعارة كتاب
# 6- عمل دالة لإرجاع كتاب
# 7- عمل دالة لعرض الكتب 
# 8- عمل دالة للخروج من البرنامج
#-------------------------------------------------

# 1 القاموس
books = {}

import os
# 2 مسح الشاشة
def clear_screen():
    os.system ('cls' if os.name == 'nt' else 'coler' )

# 3 عرض القائمة
def menw():
    print("Menu:")
    print("1. Add a book")
    print("2. Check out books")
    print("3. Check in books")
    print("4. List books")
    print("5. Exit")
    choice = input("Enter your choice (1-5): ")

    if choice == '1':
        add_books()
    elif choice == '2':
        out_books()
    elif choice == '3':
        in_books()
    elif choice == '4':
        view_books()
    elif choice == '5':
        exit_prog()

# 4 إضافة الكتاب
def add_books():
    isbn = input("Enter ISBN: ")
    title = input("Enter title: ")
    author = input("Enter author: ")
    books[isbn] = {'title':title, 'author':author, "Availabel":True}
    print(f"Book '{title}' by '{author}' added to the catalog with ISBN '{isbn}' ")
    add_book = input("Do you want add another book? (y/n): ")
    if add_book == 'y':
        clear_screen()
        add_books()
    else:
        menw()
        

# 5 استعارة كتاب
def out_books():
    clear_screen()
    isbn_out = input("Enter ISBN to check out: ")
    if isbn_out in books:    # يقترح اضافة شرط اند ترو
        books[isbn_out]['Availabel'] = False
        print(f"Book {books[isbn_out]['title']} checked out successfully.")
        another_out_books = input("Do you to check  another book? (y/n): ")
        if another_out_books == 'y':
            out_books()
        else:
            menw()
    else:
        print("sorry, the book is currently checked out.")

# 6 إرجاع كتاب
def in_books():
    clear_screen()
    while True:
        isbn_in = input("Enter ISBN to check in: ")
        if isbn_in not in books:
            print("Book not found in the cotalog.")
            another_in_books = input("Do you want to check  another book? (y/n)")
            if another_in_books == 'y':
                continue
            else:
                menw()
        else:
            books[isbn_in]['Availabel'] = True
            print(f"Book {books[isbn_in]['title']} checked in successfully.")
            another_in_books_2 = input("Do you want to check  another book? (y/n)")
            if another_in_books_2 == 'y':
                continue                
            else:
                menw()

# 7 عرض الكتب
def view_books():
    clear_screen()
    print(books)
    back_to_menu = input("Do you want to go back to the main menu? (y/n)")
    if back_to_menu == 'y':
        menw()
    else:
        print("Exiting...")
        exit()

# 8 الخروج
def exit_prog():
    print("Exiting...")
    exit()

menw()

4 إعجابات

بمأن الكود يعمل بتسلسل منطقي فحلك صحيح حتى لو لم يكن مثل حل المستر

4 إعجابات

كل الإحترام لك على هذا الحل الممتاز :saluting_face:

4 إعجابات