-
Notifications
You must be signed in to change notification settings - Fork 0
/
bunga.py
45 lines (28 loc) · 954 Bytes
/
bunga.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
flowers= []
class Bunga:
def __init__(self,nama,kelopak,harga):
self.nama = nama
self.kelopak = kelopak
self.harga = harga
def cetak(self):
return f'nama bunga {self.nama}, jumlah kelopak {self.kelopak}, harganya {self.harga}'
while True:
pilihan = input("masukkan (y/n)")
if pilihan == "y":
nama_bunga = input("nama bunga : ")
kelopak_bunga = int(input("berapa kelopak bunga: "))
harga_bunga = float(input("berapa harganya: "))
flower = Bunga(nama_bunga,kelopak_bunga,harga_bunga)
flowers.append(flower)
elif pilihan == "n":
break
for x in flowers:
print(x.cetak())
'''
@classmethod
def class_method(cls):
nama = input("Masukkan Nama bunga: ")
kelopak = int(input("Masukkan jumlah kelopak: "))
harga = float(input ("Masukkan Harga bunga: "))
return (nama,kelopak,harga)
'''