Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ahmad Dzikrul Fikri
1806196806-DDP1
Commits
85433823
Commit
85433823
authored
Mar 09, 2020
by
Ahmad Dzikrul Fikri
Browse files
Tugas Pemrograman 6 - Tahap 1 - 1806196806
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
TP6_1806196806.py
0 → 100644
View file @
85433823
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment