From ef0cf737db306dc4e0f94c681c7b9a515c1b41fa Mon Sep 17 00:00:00 2001 From: reighpuy Date: Tue, 29 Nov 2022 16:11:10 +0700 Subject: [PATCH] Update (4.5) --- Data/users.txt | 5 +++++ app.py | 12 +++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Data/users.txt b/Data/users.txt index e69de29..278e84b 100644 --- a/Data/users.txt +++ b/Data/users.txt @@ -0,0 +1,5 @@ +Muhamad Khadaffy,dapi,123 +Daffy,dapii,123 +Daffy2,dapiii,123 +Daffy3,dapi3,123 +Daffy4,dapi4,123 diff --git a/app.py b/app.py index 95f9086..b2db760 100644 --- a/app.py +++ b/app.py @@ -37,7 +37,6 @@ def jeda(durasijeda): # dengan parameter jumlah durasi jeda-nya time.sleep(durasijeda) # eksekusi perintah jeda os.system("cls") # Clear screen menggunakan modul os - # ====== FUNGSI MENU ====== def MenuPertama(): jeda(1) @@ -179,8 +178,12 @@ def lihatstokbuku(): for i, v in enumerate(file, start=1): # '.split("#")', untuk memisahkan kata dengan menggunakan pemisah # a, b, c = v.split("#") + c = int(c) # 'end' memaksa menggantikan newline dengan nonkarakter - print(f"{i}. {a} ({b}) - Stok: {c}", end="") + if c == 0: + print(f"{i}. {a} ({b}) - Stok: Tidak tersedia", end="\n") + else: + print(f"{i}. {a} ({b}) - Stok: {c}", end="\n") # Memunculkan stok buku by Kode Buku def jumlahstok(Kodebuku): @@ -190,7 +193,10 @@ def jumlahstok(Kodebuku): l_no += 1 a, b, c = line.split("#") c = int(c) - return c + if c == 0: + return 'Tidak tersedia' + else: + return c # Fungsi mengurangkan stok buku ketika buku dipinjam def kuranginstokbuku(Kodebuku):