class Goods:
'''商品类'''
def __init__(self,gName,gPlace,gPleased,gprice):
self.gName = gName
self.gPlace = gPlace
self.gPleased = gPleased
self.gPrice = gprice
class Stock:
'''库存类'''
def __init__(self):
self.goods = []
self.goods.append(Goods('奶粉','第一排',99,'320'))
self.goods.append(Goods('榴莲','第二排',100,'252'))
self.goods.append(Goods('鲜花','第三排',98,'180'))
def showGoods(self):
'''显示商品'''
print('库存商品清单列表'.center(60,'-'))
for good in self.goods:
print('显示商品:{}'.format(good.gName))
print('-'.ljust(60,'-'))
def getGoodsPlace(self):
'''获取商品的位置'''
# flag = True
# getName = input('请输入商品名称:')
# for good in self.goods:
# if getName == good.gName:
# flag = False
# print(good.gPlace)
while True:
getName = input('请输入商品名称:')
for good in self.goods:
if getName == good.gName:
print('商品的位置为{}'.format(good.gPlace))
break
else:
print('您输入的货品名称不正确,请重新输入')
def getMaxPleased(self):
'''获取满意度最大的商品'''
goodPleased = 0
maxPG = self.goods[0]
for good in self.goods:
if good.gPleased > goodPleased:
# for item in self.goods:
# if item.gPleased == good.gPleased:
maxPG = good
goodPleased = good.gPleased
# return goodPleased
# return maxPG.gName
return maxPG
def showMaxPleased(self):
'''显示满意度最大的商品的信息'''
show = self.getMaxPleased()
print('满意度最大的商品的名称是:{0}\n位置在:{1}\n满意度为:{2}\n价格为:{3}'.format(show.gName,show.gPlace,show.gPleased,show.gPrice))
def showMenu(self):
'''显示菜单'''
print('欢迎使用库存管理系统'.center(60,'='))
while True:
choice = input('请输入序号——1.根据货品名称输出货品位置 2.查找客户满意度最高的商品 3.退出:').strip()
if choice == '1':
self.getGoodsPlace()
elif choice == '2':
self.showMaxPleased()
elif choice == '3':
print('谢谢使用!')
break
else:
print('请输入有效序号')
go = Stock()
#go.showMaxPleased()
go.showMenu()
商场货品
最新推荐文章于 2023-01-18 19:55:54 发布