-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
79 lines (71 loc) · 2.39 KB
/
main.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# from os import system, name
import os
import barang
import lib.ui as ui
YangDibeli = []
# Bug cek_duplikasi
ui.clearCli()
def cek_duplikasi(triger):
if int(len(YangDibeli)) > 0 :
hasil = barang.cari(str(triger[0]),YangDibeli, True)
if hasil:
YangDibeli.pop(hasil[0])
kuntitas = triger[3]
triger.pop(3)
kuntitas = int(kuntitas) + int(hasil[1][3])
triger[3] = kuntitas
return triger
return triger
def handel_pilihan_kustom():
dataKustom = ["===Kustom!==="]
namaBarang = input("Apa nama barangnya?\n")
hargaBarang = int(input("Berapa harga barangnya?\n"))
kuantitasBarang = float(input("Berapa banyak yang dibeli?\n"))
dataKustom.append(namaBarang)
dataKustom.append(hargaBarang)
dataKustom.append(kuantitasBarang)
YangDibeli.append(dataKustom)
def handel_pilihan_basis_data():
indeksPencarian = input("Masukan Nama Barang / ID-nya!\n")
hasilPencarian = barang.cari(indeksPencarian)
if hasilPencarian:
kuantitasBarang = float(input("Berapa banyak yang dibeli?\n"))
hasilPencarian.append(kuantitasBarang)
YangDibeli.append(cek_duplikasi(hasilPencarian))
# YangDibeli.append(hasilPencarian)
else:
print("Maaf barang tidak terdaftar di basis data.")
handel_pilihan_basis_data()
def penambahan_barang():
tipeInput = input("Cari barang atau masukan kustom?\n(Cari isi 1, kustom isi 0)\n")
if(int(tipeInput) == 1):
handel_pilihan_basis_data()
else:
handel_pilihan_kustom()
ui.build(YangDibeli)
def tambahAkhiri():
kataTAA = "Lanjut menambahakan barang(1) atau akhiri(0)?\n"
tambahAtauAkhiri = int(input(kataTAA))
while tambahAtauAkhiri == 1:
penambahan_barang()
tambahAtauAkhiri = int(input(kataTAA))
if len(YangDibeli) < 1:
utama()
dihapus = int(input("Apa yang mau dihapus?\n(masukan 0 bila tidak ada)\n"))
if dihapus > 0:
YangDibeli.pop(dihapus-1)
ui.build(YangDibeli)
return tambahAkhiri()
uangYgDibayar = int(input("Berapa uang yang dibayarkan?\n"))
ui.build(YangDibeli,uangYgDibayar)
return 0
def utama():
print("Selamat Datang!")
print("MESIN KASIR BASIS CLI 'CLIKAS'")
print("Dibuat Oleh:")
print("Muhammad Iqbal")
print("(5312421026)")
print("="*30)
penambahan_barang()
tambahAkhiri()
utama()