Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from class_node import*
- from main import*
- import os,sys
- import datetime
- import random
- import time
- # ------------------------------------------
- # NAMA : Muhammad Kharirrushofa
- # NIM : A11.2019.11823
- # ------------------------------------------
- class linked(object):
- """docstring for linked"""
- def __init__(self, head=None,tail=None):
- self.head=head
- self.tail=tail
- def regbuku(self,data):
- newbook=class_node.node(data)
- if(self.head is None):
- self.head=newbook
- self.tail=newbook
- else:
- self.tail.next_node=newbook
- self.tail=newbook
- def delbuku(self,posisi):
- if self.head==None:
- return
- temp=self.head
- if posisi==0:
- self.head=temp.next_node
- temp=None
- return
- for i in range(posisi -1):
- temp=temp.next_node
- if temp is None:
- break
- if temp is None:
- return
- if temp.next_node is None:
- return
- next_node=temp.next_node.next_node
- temp.next_node=None
- temp.next_node=next_node
- def menu(self):
- os.system('cls')
- print("---------------------------------FORM REGISTER BOOK APPLICATION---------------------------------")
- print("==================================================================")
- print("\t Menu : ")
- print(" 1. Registrasi Buku Baru")
- print(" 2. Hapus Data Buku")
- print(" 3. Report Modul Data Buku")
- print(" 4. EXIT")
- print("==================================================================")
- print("------------------------------------------------------------------------------------------------")
- menu1=int(input("Masukan Nomor pada pilihan menu : "))
- if menu1==1:
- while True:
- os.system('cls')
- print("---------------------------------REGISTER NEW BOOK---------------------------------")
- print("0. Back to Main Menu")
- print("")
- judul=str(input("Masukan Judul Buku: "))
- if judul=="0":
- self.menu()
- else:
- self.regbuku(judul)
- digit=random.randint(0,999999)
- print("Kode Registrasi: ",digit)
- print("\n")
- elif menu1==2:
- os.system('cls')
- print("---------------------------------DELETE DATA BUKU---------------------------------")
- print("------------------------------------------------------------------------------")
- print("| KODE REGISTRASI | | \tNAMA BUKU\t | | TANGGAL INPUT |")
- print("| \t {} \t | \t \t| \t {}\t \t |\t \t| \t {}\t|")
- # self.result()
- print("------------------------------------------------------------------------------")
- print("------------------------------------------------------------------------------")
- print("0. Back to Main Menu")
- print("")
- hapus=str(input("Masukan Code Registrasi buku yang akan dihapus: "))
- if judul=="0":
- self.menu()
- else:
- self.hapusBuku(hapus)
- self.showData()
- elif menu1==3:
- os.system('cls')
- x=datetime.datetime.now()
- print("---------------------------------DETAIL REPORT MODUL DATA BUKU---------------------------------")
- print("")
- print("-----------------------------------------------------------------------------------------")
- print("| KODE REGISTRASI | | \tNAMA BUKU\t | | TANGGAL INPUT |")
- self.showData()
- print("-----------------------------------------------------------------------------------------")
- print("-----------------------------------------------------------------------------------------------")
- back=int(input("Tekan 0 untuk kembali ke Main Menu = "))
- if back=="0":
- self.menu()
- else:
- print("Perintah Salah")
- #print(ct) #countdown
- self.menu()
- elif menu1==4:
- os.system('cls')
- else:
- print("Salah Input")
- self.menu()
- def showData(self):
- x=datetime.datetime.now()
- CNode=self.head
- if(self.head is None):
- print("Data Not Exist")
- else:
- while CNode is not None:
- print("| \t {} \t | \t \t| \t {}\t \t |\t \t| \t test\t|",CNode.data,CNode.data,)
- # print(CNode.data,'\n')
- CNode=CNode.next_node
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement