Fakultas Ilmu Komputer UI

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

Tugas Pemrograman 6 - Tahap 1 - 1806196806

parents
import urllib.request
def cari_nilai(pilihan,kesulitan):
page = urllib.request.urlopen("https://baguspribadi99.github.io/difficulty/difficulty.html")
text = page.read().decode("utf8")
sebelum = text.find(kesulitan)
cari_li = text.find('</li>',text.find(pilihan,sebelum))
return int(text[text.find(pilihan,sebelum)+len(pilihan+': '):cari_li])
kesulitan = input("masukkan tingkat kesulitan yang diinginkan:").lower
hp_student = cari_nilai('hp-student',kesulitan)
hp_kuliah = cari_nilai('kuliah',kesulitan)
attack_student = cari_nilai('attack-student',kesulitan)
attack_kuliah = cari_nilai('attack-kuliah',kesulitan)
print("Berikut atribut objek :")
print("- Student, HP =",hp_student,"attack =",attack_student)
print("- Kuliah, HP =",hp_kuliah,"attack =",attack_kuliah)
while hp_student>0 or hp_kuliah>0 :
jawaban = True
while jawaban == True:
action = input("Masukkan action untuk student!! :").lower()
if action == 'serang':
hp_kuliah-= attack_student
print("Student mengerjakan tugas, HP kuliah berkurang sebanyak",attack_student)
jawaban = False
elif action == 'istirahat':
hp_student = 100
print("Student istirahat, HP student pulih kembali")
jawaban = False
else:
print(action,"tidak termasuk kedalam pilihan.(serang atau istirahat)")
jawaban == True
jawaban = True
while jawaban== True:
action = input("Masukkan action untuk kuliah!! :").lower()
if action == 'serang':
hp_student-= attack_kuliah
print("Deadline menghantui student, HP student berkurang sebanyak",attack_kuliah)
jawaban = False
elif action == 'bertahan':
hp_kuliah += attack_kuliah
print("Ada revisi, HP kuliah bertambah sebanyak",attack_kuliah)
jawaban = False
else:
print(action,"tidak termasuk kedalam pilihan.(serang atau bertahan)")
jawaban == True
if hp_kuliah <=0 :
print("Selamat anda telah mengalahkan tugas-tugas kuliah!")
else :
print("Sayang sekali anda telah dimakan oleh beratnya tugas kuliah!")
\ 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