




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
第python實現(xiàn)超市進銷存管理系統(tǒng)本文實例為大家分享了python實現(xiàn)超市進銷存管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
面向?qū)ο蟪绦蛟O(shè)計
系統(tǒng)包括7種操作,分別是:1.查詢所有商品;2.添加商品;3.修改商品;4.刪除商品;5.賣出商品;6.匯總;0.退出系統(tǒng)。
定義一個商品類
#定義一個商品類
classGoods:
def__init__(self,name,num,cin,cout):
=name
self.num=num
self.cin
=cin
self.cout=cout
def__str__(self):
state="已售罄"
ifself.num==0:
return'名稱:%s,數(shù)量:%d%s,進貨價格:%.2f,售出價格:%.2f'%(,self.num,state,self.cin,self.cout)
else:
return'名稱:%s,數(shù)量:%d,進貨價格:%.2f,售出價格:%.2f'%(,self.num,self.cin,self.cout)
定義一個匯總類
#定義一個匯總類
classgGoods:
def__init__(self,name,gnum,gcin,gcout):
=name
self.gnum=gnum
self.gcin=gcin
self.gcout=gcout
def__str__(self):
return'名稱:%s,賣出數(shù)量:%d,進貨價格:%.2f,賣出價格:%.2f'%(,self.gnum,self.gcin,self.gcout)
定義管理商品類
#定義管理商品類
classGoodsManager:
go=[]
js=[]
#構(gòu)造方法
definit(self):
self.go.append(Goods('牛奶',5,40,60))
self.go.append(Goods('盒飯',5,10,60))
self.js.append(gGoods('菇娘',1,30,60))
#菜單
defMenu(self):
self.init()
print('\"超市進銷存管理系統(tǒng)\"菜單:')
print("1.顯示所有商品")
print("2.添加新的商品")
print("3.修改商品信息")
print("4.刪除商品")
print("5.賣出商品")
print("6.匯總")
print("0.退出")
print("***********************************")
whileTrue:
SN=int(input("===請輸入操作序號:"))
ifSNin[0,1,2,3,4,5,6]:
ifSN==0:
print("已經(jīng)退出")
break;
ifSN==1:
self.Show_all()
elifSN
==2:
self.Add()
elifSN==3:
self.Modify()
elifSN==4:
self.Delete()
elifSN==5:
self.Shop()
elifSN==6:
self.Summary()
else:
print("輸入有誤!")
#顯示
defShow_all(self):
forgoodsinself.go:
print(str(goods))
#添加
defAdd(self):
goods_name=input("請輸入商品名稱:")
ret=self.check(goods_name)
ifret!=None:
print('商品已經(jīng)存在')
print('是否增加商品數(shù)量:(y/n)')
whileTrue:
pd=input()
ifpd=='y':
goods_num=int(input("請輸入商品的數(shù)量:"))
old_goods=Goods(goods_name,goods_num+ret.num,ret.cin,ret.cout)
self.go.remove(ret)
self.go.append(old_goods)
print("增加成功")
break
elifpd=='n':
print("已經(jīng)返回")
break
else:
print("輸入有誤,重新輸入:")
else:
goods_num=int(input("請輸入商品的數(shù)量:"))
goods_cin=float(input("請輸入商品進貨價格:"))
goods_cout=float(input("請輸入商品出貨價格:"))
ifgoods_num0andgoods_cin0andgoods_cout0:
new_goods=Goods(goods_name,goods_num,goods_cin,goods_cout)
self.go.append(new_goods)
print("添加成功")
else:
print("小可愛,輸入錯誤!")
#修改
defModify(self):
goods_name=input("請輸入需要修改的商品名稱:")
ret=self.check(goods_name)
ifret!=None:
print(ret)
goods_name1=input("請輸入修改后商品的名稱:")
goods_num=int(input("請輸入修改后商品的數(shù)量:"))
goods_cin=float(input("請輸入修改后商品進貨價格:"))
goods_cout=float(input("請輸入修改后商品出貨價格:"))
old_goods=Goods(goods_name1,goods_num,goods_cin,goods_cout)
self.go.remove(ret)
self.go.append(old_goods)
print("修改成功")
else:
print("小可愛,沒有此商品!")
#檢查
defcheck(self,goods_name):
forgoodsinself.go:
if==goods_name:
returngoods
else:
returnNone
#檢查js
defcheckjs(self,goods_name):
forgoodsinself.js:
if==goods_name:
returngoods
else:
returnNone
#刪除
defDelete(self):
goods_name=input("請輸入需要刪除的商品名稱:")
ret=self.check(goods_name)
ifret!=None:
print(ret)
print('是否刪除商品:(y/n)')
whileTrue:
pd=input()
ifpd=='y':
self.go.remove(ret)
print("刪除成功")
break
elifpd=='n':
print("已經(jīng)返回")
break
else:
print("輸入有誤,重新輸入:")
else:
print("小可愛,沒有此商品!")
#賣出
defShop(self):
goods_name=input("請輸入需要賣出的商品名稱:")
ret=self.check(goods_name)
ifret!=None:
g_num=int(input("賣出個數(shù):"))
ifret.num-g_num0:
print("該商品數(shù)量不足!請補充")
else:
old_goods=Goods(,ret.num-g_num,ret.cin,ret.cout)
self.go.remove(ret)
self.go.append(old_goods)
gret=self.checkjs(goods_name)
ifgret==None:
shop_goods=gGoods(,g_num,ret.cin*g_num,ret.cout*g_num)
self.js.append(shop_goods)
else:
shop_goods=gGoods(,g_num+gret.gnum,gret.gcin+ret.cin*g_num,gret.gcout+ret.cout*g_num)
self.js.remove(gret)
self.js.append(shop_goods)
print("賣出后:",e
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 【正版授權(quán)】 IEC 61196-1-102:2025 RLV EN Coaxial communication cables - Part 1-102: Electrical test methods - Test for insulation resistance of cable dielectric
- 【正版授權(quán)】 IEC 61225:2025 EN Nuclear power plants - Instrumentation,control and electrical power systems - Requirements for static uninterruptible DC and AC power supply systems
- 小學生心理健康直面青春期
- 健康素養(yǎng)課件模板下載
- 半導體技術(shù)課件第八
- 健康管理師招生課件
- 白慕大行業(yè)深度研究分析報告(2024-2030版)
- 新建氮化鎵外延片項目可研報告-圖文
- 中國仲丁靈行業(yè)市場調(diào)研及未來發(fā)展趨勢預(yù)測報告
- 中國核磁共振成像行業(yè)市場調(diào)查研究及投資前景預(yù)測報告
- 2025年陜西延長石油招聘筆試備考題庫(帶答案詳解)
- midas分析設(shè)計原理
- 初一英語時態(tài)專題復習(附答案)
- 2022年上高縣教師進城考試筆試題庫及答案解析
- 質(zhì)量管理手冊(隧道)(中交路橋建設(shè)有限公司)
- 黃大年式教學團隊申報材料
- 出香港貨物發(fā)票樣板樣本空白
- 醫(yī)院免疫室標準化操作程序免疫室內(nèi)質(zhì)量控制操作指南(ELISA)人民醫(yī)院檢驗科免疫SOP人民醫(yī)院質(zhì)量管理體系課件
- 柳州市柳東新區(qū)南慶安置區(qū)項目工程基坑支護方案
- 卵巢腫瘤ppt課件
- 發(fā)電可靠性考試真題及答案
評論
0/150
提交評論