Fakultas Ilmu Komputer UI

Commit c63731dd authored by Ahmad Dzikrul Fikri's avatar Ahmad Dzikrul Fikri
Browse files

Tugas Pemrograman - Tahap 3 - 1806196806

parent 6228baa6
import urllib.request
def ambil_info_stok():
page = urllib.request.urlopen("https://ceritanyatuwiter.herokuapp.com/1806196806")
def ambil_info_stok(NPM):
page = urllib.request.urlopen("https://ceritanyatuwiter.herokuapp.com/"+NPM)
text = page.read().decode("utf8")
awal = text.find('Terkini: ')
akhir = text.find('</',awal)
......@@ -13,17 +13,28 @@ def laporkan_stok(stok_sekarang):
def request_stok():
laporkan_stok("@burhan request restock untuk saya")
stok = int(ambil_info_stok())
disalurkan = 1
while stok>0 and disalurkan >0:
disalurkan = int(input("Berapa jumlah tabung gas yang ingin disalurkan:"))
if disalurkan>0:
if disalurkan>stok :
print("Stok tidak cukup")
else:
print("Penyaluran",disalurkan,"tabung berhasil, sekarang tersisa",stok-disalurkan)
laporkan_stok("Stok Terkini: "+str(stok-disalurkan))
if stok - disalurkan == 0 :
print("\nSedang meminta kak burhan restock tabung gas\n")
request_stok()
stok = int(ambil_info_stok())
\ No newline at end of file
perintah = ""
while perintah != 'keluar':
perintah = input("Masukkan perintah (salurkan, cek agen, keluar):").lower()
if perintah == 'salurkan':
stok = int(ambil_info_stok('1806196806'))
disalurkan = 1
while stok>0 and disalurkan >0:
disalurkan = int(input("Berapa jumlah tabung gas yang ingin disalurkan:"))
if disalurkan>0:
if disalurkan>stok :
print("Stok tidak cukup")
else:
print("Penyaluran",disalurkan,"tabung berhasil, sekarang tersisa",stok-disalurkan)
laporkan_stok("Stok Terkini: "+str(stok-disalurkan))
if stok - disalurkan == 0 :
print("\nSedang meminta kak burhan restock tabung gas\n")
request_stok()
stok = int(ambil_info_stok('1806196806'))
elif perintah.startswith('cek') == True:
npm = input("Masukkan NPM agen:")
print("stok agen",npm,"sejumlah",ambil_info_stok(npm),"tabung")
elif perintah == 'keluar':
print("Selesai!")
else :
print("Perintah tidak valid")
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment