Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
081e6df
arkadaşlar bazı sayfaları yaptım ama kitap çdünc alam kısmı ile json …
cafersonmez May 6, 2025
acf0ff3
all
cafersonmez May 6, 2025
f09d168
Update main.py
cafersonmez May 6, 2025
1710cf1
a
cafersonmez May 6, 2025
433a81f
00,16
cafersonmez May 6, 2025
58698ce
main e book actions u ekledim. Book actions page oluşturdum. orada bo…
cafersonmez May 7, 2025
ed11980
Create ic_week_4_clsm.py
icubuk May 7, 2025
ef2efc0
Update ic_week_4_clsm.py
icubuk May 8, 2025
9398859
Create book_actions.cpython-313.pyc
icubuk May 8, 2025
e26ffbe
Update functions.cpython-313.pyc
icubuk May 8, 2025
36befd8
Update Kitap_transactions.cpython-313.pyc
icubuk May 8, 2025
5551162
Update Member_Transactions.cpython-313.pyc
icubuk May 8, 2025
5d81818
Update Kitap_transactions.py
icubuk May 8, 2025
ba5b301
Update Member_Transactions.py
icubuk May 8, 2025
a96fa7e
Create members.json
icubuk May 8, 2025
52f282e
Update main.py
icubuk May 8, 2025
5acb5f1
Update members.json
icubuk May 8, 2025
270e924
Update main.py
mithat720 May 8, 2025
137dc89
a
cafersonmez May 8, 2025
36a128a
a
cafersonmez May 8, 2025
27f2e0c
book_actions
Bestfullmoon May 9, 2025
ab4ff3c
new
Bestfullmoon May 9, 2025
c5831de
new
Bestfullmoon May 9, 2025
be17e74
week 4
Bestfullmoon May 9, 2025
b4b8a42
updated
mithat720 May 10, 2025
326bde8
a
cafersonmez May 10, 2025
09b28dc
2
cafersonmez May 10, 2025
da11354
a
cafersonmez May 10, 2025
59cf13f
Update members.json
cafersonmez May 10, 2025
ed1c1e3
3
cafersonmez May 10, 2025
27713f6
c
cafersonmez May 10, 2025
6ccf1de
d
cafersonmez May 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Library Project/library project/.vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\cafer\\OneDrive\\Documents\\Veri Kaynaklar\u0131m\\Python_Modul_Week_4\\Library Project\\library project\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": []
}
]
}
Binary file not shown.
97 changes: 97 additions & 0 deletions Library Project/library project/Kitap_transactions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import json
import os


from functions import menu_add
from functions import menu_delete
from functions import main_menu

# Kitapları JSON'dan yükle
books_file = "books.json"
if os.path.exists(books_file):
with open(books_file, "r", encoding="utf-8") as f:
books = json.load(f)
else:
books = []

def save_books():
with open(books_file, "w", encoding="utf-8") as f:
json.dump(books, f, ensure_ascii=False, indent=4)

def book_list():
print("List of books")
print("Barkod, Dil, Fiyat, Kitap_Adi, Yayinevi, Yazar")
for i in books_file:
print(books_file)
#print(f"Barkod: {i['Barkod']}, Dil: {i['Dil']}, Fiyat: {i['Fiyat']}, Kitap_Adi: {i['Kitap_Adi']}, Yayinevi: {i['Yayinevi']}, Yazar: {i['Yazar']}")


def book_add():
print("Add a new book")
book_barekod = int(input("Book barekod: "))
book_language = input("Book language: ")
book_price = float(input("Book price: "))
book_name = input("Book name: ")
book_house = input("Book house: ")
book_author = input("Book author: ")
book_new = { "Barkod": book_barekod, "Dil": book_language, "Fiyat" : book_price, "Kitap_Adi" : book_name, "Yayinevi" : book_house, "Yazar" : book_author}
books.append(book_new)
print("------------Book added----------")
books_print(books)
save_books()

def books_print(books):
print("Books in the library:")
print("Barkod, Dil, Fiyat, Kitap_Adi, Yayinevi, Yazar")
for i in books:
print(f"Barkod: {i['Barkod']}, Dil: {i['Dil']}, Fiyat: {i['Fiyat']}, Kitap_Adi: {i['Kitap_Adi']}, Yayinevi: {i['Yayinevi']}, Yazar: {i['Yazar']}")

def book_update():
print("Update a book")
book_id = int(input("Book id: "))
for i in books:
if i["Barkod"] == book_id:
book_barekod = int(input("Book barekod: "))
book_language = input("Book language: ")
book_price = float(input("Book price: "))
book_name = input("Book name: ")
book_house = input("Book house: ")
book_author = input("Book author: ")
i["Barkod"] = book_barekod
i["Dil"] = book_language
i["Fiyat"] = book_price
i["Kitap_Adi"] = book_name
i["Yayinevi"] = book_house
i["Yazar"] = book_author
print(f"Book with id {book_id} updated.")
books_print(books)
save_books()


def book_delete_id():
print("Delete with barekod")
book_id = int(input("Book barekod: "))
for i in books:
if i["Barkod"] == book_id:
books.remove(i)
print(f"Book with barkod {book_id} deleted.")
save_books()
books_print(books)
break
else:
print(f"No book found with barekod: {book_id}")

def book_delete_name():
print("Delete with name")
book_name = input("Book name: ")
for i in books:
if i["Kitap_Adi"] == book_name: # ✅ Doğru anahtar adı
books.remove(i)
print(f"Book with name {book_name} deleted.")
save_books() # ✅ Değişikliği dosyaya kaydet
books_print(books)
break
else:
print(f"No book found with name: {book_name}")


40 changes: 40 additions & 0 deletions Library Project/library project/Member_Transactions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import json
import os

members_file = "members.json"
if os.path.exists(members_file):
with open(members_file, "r", encoding="utf-8") as f:
members = json.load(f)
else:
members = []

def save_members():
with open(members_file, "w", encoding="utf-8") as f:
json.dump(members, f, ensure_ascii=False, indent=4)

def members_print(members):
for i in members:
print(f"Id: {i['id']}, Name: {i['name']}, Tel: {i['tel']}, Time: {i['date']}, Adress: {i['adress']}")

def member_add(x):
print(f"{x} add menu")
print("---------------------------------------")
member_id = int(input(f"{x} id: "))
member_name = (input(f"{x} name: "))
member_tel = int(input(f"{x} tel: "))
member_time = int(input(f"{x} time: "))
member_adress = (input(f"{x} address: "))
print("---------------------------------------")
member_new= { "id": member_id,
"name": member_name,
"tel" : member_tel,
"date" : member_time,
"adress" : member_adress}
members.append(member_new)
members_print(members)
save_members()
print("------------Member added----------")




Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
137 changes: 137 additions & 0 deletions Library Project/library project/book_actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# def book_actions_menu():
# print("1. Borrow Book")
# print("2. Return Book")
# print("3. Reserve Book")
# print("4. Cancel Reservation")
# print("5. List Borrowed Books")
# print("6. List Reserved Books")
# print("7. Exit")
# return int(input("Select an action: "))


import json
import os

BOOKS_FILE = "books.json"

def load_books():
if os.path.exists(BOOKS_FILE):
with open(BOOKS_FILE, "r", encoding="utf-8") as f:
return json.load(f)
return []

def save_books(books):
with open(BOOKS_FILE, "w", encoding="utf-8") as f:
json.dump(books, f, ensure_ascii=False, indent=4)

def borrow_book():
books = load_books()
barcode = input("Enter book barcode to borrow: ")
member_name = input("Enter member name: ")

for book in books:
if str(book["Barkod"]) == barcode:
if book.get("status") == "borrowed":
print("Book is already borrowed.")
return
book["status"] = "borrowed"
book["borrowed_by"] = member_name
print(f"Book '{book['Kitap_Adi']}' borrowed by {member_name}.")
save_books(books)
return

print("Book not found.")

def return_book():
books = load_books()
barcode = input("Enter book barcode to return: ")

for book in books:
if str(book["Barkod"]) == barcode and book.get("status") == "borrowed":
book["status"] = "available"
book.pop("borrowed_by", None)
print(f"Book '{book['Kitap_Adi']}' has been returned.")
save_books(books)
return

print("Book not found or not borrowed.")

def reserve_book():
books = load_books()
barcode = input("Enter book barcode to reserve: ")
member_name = input("Enter member name: ")

for book in books:
if str(book["Barkod"]) == barcode:
if book.get("status") == "available" or book.get("status") ==None:
book["status"] = "reserved"
book["reserved_by"] = member_name
print(f"Book '{book['Kitap_Adi']}' reserved by {member_name}.")
save_books(books)
return
else:
print(f"Book is not available. Current status: {book.get('status')}")
return

print("Book not found.")

def cancel_reservation():
books = load_books()
barcode = input("Enter book barcode to cancel reservation: ")
member_name = input("Enter member name: ")

for book in books:
if (str(book["Barkod"]) == barcode and
book.get("status") == "reserved" and
book.get("reserved_by") == member_name):
book["status"] = "available"
book.pop("reserved_by", None)
print(f"Reservation for '{book['Kitap_Adi']}' canceled.")
save_books(books)
return

print("Reservation not found.")

def list_borrowed_books():
books = load_books()
borrowed = [book for book in books if book.get("status") == "borrowed"]
if borrowed:
print("Borrowed Books:")
for b in borrowed:
print(f"{b['Kitap_Adi']} - Borrowed by: {b['borrowed_by']}")
else:
print("No books are currently borrowed.")

def list_reserved_books():
books = load_books()
reserved = [book for book in books if book.get("status") == "reserved"]
if reserved:
print("Reserved Books:")
for b in reserved:
print(f"{b['Kitap_Adi']} - Reserved by: {b['reserved_by']}")
else:
print("No books are currently reserved.")

def show_all_books():
books = load_books()
print("All Book Records:")
for book in books:
print(book)

def book_actions_menu():
print("\nBook Actions Menu:")
print("1. Borrow Book")
print("2. Return Book")
print("3. Reserve Book")
print("4. Cancel Reservation")
print("5. List Borrowed Books")
print("6. List Reserved Books")
print("7. List All Books")
print("8. Exit")

try:
return int(input("Select an action: "))
except ValueError:
print("Invalid input, please enter a number.")
return 0 # 0 döndürülürse, bir hata yapıldığında tekrar menüye dönülür.

Loading