Contoh program kasir-restoran sederhana dengan menggunakan python..
class makanan :
def bakso (self,x):
jmlhpsn = x * 7000
print 'total makanan = ',jmlhpsn
return jmlhpsn
def mieayam (self,x):
jmlhpsn = x * 6000
print 'total makanan = ',jmlhpsn
return jmlhpsn
def sotoayam (self,x):
jmlhpsn = x * 7500
print 'total makanan = ',jmlhpsn
return jmlhpsn
def sotomie (self,x):
jmlhpsn = x * 8000
print 'total makanan = ',jmlhpsn
return jmlhpsn
def gadogado (self,x):
jmlhpsn = x * 5000
print 'total makanan = ',jmlhpsn
return jmlhpsn
class minuman :
def airmineral (self,z):
jmlhpsn1 = z * 3000
print 'total minuman = ',jmlhpsn1
return jmlhpsn1
def estehmanis (self,y):
jmlhpsn1 = z * 2000
print 'total minuman = ',jmlhpsn1
return jmlhpsn1
def jusjeruk (self,z):
jmlhpsn1 = z * 3500
print 'total minuman = ',jmlhpsn1
return jmlhpsn1
def jusalpukat (self,z):
jmlhpsn1 = z * 5000
print 'total minuman = ',jmlhpsn1
return jmlhpsn1
def jusmelon (self,z):
jmlhpsn1 = z * 4000
print 'total minuman = ',jmlhpsn1
return jmlhpsn1
print """Kasir Pembayaran :
1. Bayar
2. Keluar """
t=input("Masukan Pilihan : ")
if t==1:
mk = makanan()
pil=1
while pil !=6:
print """Pilih Makanan
1. BAKSO
2. MIE AYAM
3. SOTO AYAM
4. SOTO MIE
5. GADO - GADO
6. Minuman"""
pil = int (input('Masukkan pilihan anda : '))
print
if pil == 1:
print ("")
x = input ('Jumlah porsi : ')
mk.bakso(x)
pil=6
if pil == 2:
print ("")
x = input ('Jumlah porsi : ')
mk.mieayam(x)
pil=6
if pil == 3:
print ("")
x = input ('Jumlah porsi : ')
mk.sotoayam(x)
pil=6
if pil == 4:
print ("")
x = input ('Jumlah porsi : ')
mk.sotomie(x)
pil=6
if pil == 5:
print ("")
x = input ('Jumlah porsi : ')
print
pil=6
pil = 0
mn = minuman()
while pil !=6:
print """Pilih Minuman
1. Air mineral
2. Es teh manis
3. Jus Jeruk
4. Jus Alpukat
5. Jus Melon"""
pil = int (input('Masukkan pilihan anda : '))
print
if pil == 1:
print ("")
z = input ('Jumlah gelas : ')
mn.airmineral(z)
pil=6
if pil == 2:
print ("")
z = input ('Jumlah gelas : ')
mn.estehmanis(z)
pil=6
if pil == 3:
print ("")
z = input ('Jumlah gelas : ')
mn.jusjeruk(z)
pil=6
if pil == 4:
print ("")
z = input ('Jumlah gelas : ')
mn.jusalpukat(z)
pil=6
if pil == 5:
print ("")
z = input ('Jumlah gelas : ')
mn.jusmelon(z)
pil=6