06.05 自我总结

一.面向对象编程

​面向过程编程,核心是编程二字,过程指的是解决问题的步骤,即先干什么、后干什么、再干什么、然后干什么……

与工厂的工艺流程差不多,前后都有影响

优点:复杂的问题流程化,进而简单化,调理清晰.

缺点:拓展性不行

二.对于我之前写的一个购物程序

total_prices = 0

def chiose(action):

'''0是注册功能,1是会员卡系统,2是购物功能,3是会员查找积分功能,4为会员积分兑换功能'''

#注册功能

if action == 0:

# 注册内容

def register():

while True:

print('注册账号'.center(50, "-"))

name = input('请输入账号').strip()

print('注册密码'.center(50, "-"))

pwd = input('请输入密码').strip()

pwd_next = input('请再一次输入入密码').strip()

with open('用户注册信息.txt', 'a+', encoding='utf8') as fw:

fw.seek(0)

data = fw.read()

if name in data :

print('已有账号')

continue

else:

if pwd == pwd_next:

print('注册成功')

with open('用户注册信息.txt', 'a', encoding='utf8') as fw:

fw.write(f'{name}:{pwd}|')

break

else:

print('两次输入密码不同')

print(50*'-')

return register

# 会员卡功能,100块钱1分

# 其中加个必须结合shoping进行

#小于10分是普通会员9折优惠

#大于等于10分是黄金会员8.5折优惠

# 大于等于100分是至尊会员打8折

if action == 1:

def member():

choise = input('有会员输入1\n'

'没会员输入其他\n'

'最终解释权归杨文益所有')

count = 0

if choise == '1':

while count == 0:

info_dict = dict()

member_dict = dict()

new_member_dict = dict()

print('登入账号'.center(50, "-"))

name = input('请输入账号(真的想不起来了,输入我忘了密码随意退出)\n').strip()

print('登入密码'.center(50, "-"))

pwd = input('请输入密码').strip()

with open('用户注册信息.txt', 'a+', encoding='utf8') as fr:

fr.seek(0)

info = fr.read()

if info == '':

print('没有注册请先注册')

return

info_list = info.split('|')

for info in info_list[:-1]:

info = info.split(':')

info_name = info[0]

info_pwd = info[1]

info_dict[info_name] = info_pwd

if name == '我忘了':

print(50 * '-')

count = 1

elif name not in info_dict:

print('会员账号错误')

continue

elif pwd != info_dict.get(name):

print('密码错误')

continue

else:

print('会员成功')

count = 1

# 写入会员名字加积分

with open('会员积分.txt', 'a', encoding='utf8') as fw,\

open('会员积分剩余积分.txt', 'a', encoding='utf8') as fw_1:

fw.write(f'{name}:{total_prices / 100}|')

fw_1.write(f'{name}:{total_prices / 100}|')

# 读写会员总积分

with open('会员积分.txt', 'r', encoding='utf8') as fw:

member = fw.read()

member_list = member.split('|')

for member in member_list[:-1]:

member = member.split(':')

member_name = member[0]

member_integral = float(member[1])

if member_name not in member_dict:

member_dict[member_name] = member_integral

else:

member_dict[member_name] += member_integral

# 读写会员剩余积分

with open('会员积分剩余积分.txt', 'r', encoding='utf8') as fw:

new_member = fw.read()

new_member_list = new_member.split('|')

for new_member in new_member_list[:-1]:

new_member = new_member.split(':')

new_member_name = new_member[0]

new_member_integral = float(new_member[1])

if new_member_name not in new_member_dict:

new_member_dict[new_member_name] = new_member_integral

else:

new_member_dict[new_member_name] += new_member_integral

# 打印积分

print(50 * '-')

print(f'你好{name}')

print(f'您当前的积分{member_dict.get(name)}分')

integral = member_dict.get(name)

if integral < 10:

print(50 * '-')

print('您是我们超市的普通会员可以享受9折优惠')

print(50 * '-')

print(f'你本次购买总计:{total_prices}')

print(f'会员折扣后为{0.9*total_prices}')

print(50 * '-')

print(f'请到前台支付{0.9 * total_prices}')

print(50 * '-')

print('欢迎下次光临'.center(44,"-"))

elif integral < 100:

print(50 * '-')

print('您是我们超市的黄金会员可以享受8.5折优惠')

print(50 * '-')

print(f'你本次购买总计:{total_prices}')

print(f'会员折扣后为{0.85 * total_prices}')

print(50 * '-')

print(f'请到前台支付{0.85 * total_prices}')

print(50 * '-')

print('欢迎下次光临'.center(44, "-"))

else:

print(50 * '-')

print('您是我们超市的至尊会员可以享受8折优惠')

print(50 * '-')

print(f'你本次购买总计:{total_prices}')

print(f'会员折扣后为{0.8 * total_prices}')

print(50 * '-')

print(f'请到前台支付{0.8 * total_prices}')

print(50 * '-')

print('欢迎下次光临'.center(44, "-"))

print(50 * '-')

return member

#购物系统

if action == 2:

def shopping():

# 产品成功选择后用judge = 1跳转到继续,结清,清空选择列表

# 选择产品后继续 jump == '1'跳转,结算用jump == '0' 跳转, 清空继续购买用jump == '2'跳转,清空退出购买用jump == '3'跳转

# 用 a == '0' 控制继续购买, a =='1'控制退出购买

commodity_dict = {

'0': ['cat', 100],

'1': ['dog', 200],

'2': ['pig', 300]

}

user_dict = dict()

a = '0'

print('欢迎来选购'.center(50, "-"))

while a == '0':

chiose = input('输入0商品是cat\n'

'输入1商品是dog\n'

'输入2商品是pig\n'

'请选择你要购买的商品:')

print(50 * '-')

commodity_info = commodity_dict.get(chiose)

num = input('请输入你选择商品的数量')

# 判断输入内容

if not num.isdigit():

print('数量输入有误请重新输入,数量只能输入数字')

continue

if chiose not in commodity_dict:

print('无效商品,请在0,1,2中选择输入')

continue

# 整理商品清单

else:

num_int = int(num)

if commodity_info[0] not in user_dict:

user_dict[commodity_info[0]] = [num_int, num_int * commodity_info[1]]

judge = 1 # 跳转选择界面

a = '1'

else:

user_dict[commodity_info[0]][0] += num_int

user_dict[commodity_info[0]][1] += num_int * commodity_info[1]

judge = 1 # 跳转选择界面

a = '1'

# 打印购买信息

global total_prices

total_prices = 0

print("\n")

print('杨大爷超市欢迎您'.center(42, '-'))

print('\n你选择的商品')

for name, info_list in user_dict.items():

print(f'{name}{info_list[0]}个合计{info_list[1]}元\n')

total_prices += info_list[1]

print(50 * '-')

print(f' 总计{total_prices}元')

# 功能选择

while judge == 1:

print(50 * '-')

jump = input('输入0结算\n'

'输入1继续购买\n'

'输入2清空购物车继续购买\n'

'输入3清空购物车退出\n'

'请输入您的选择').strip()

if not jump.isdigit():

print('请正确输入0,1,2,3中任意数字')

continue

if jump == '1':

judge = 4 # 跳出功能选择

a = '0' # 继续购买

elif jump == '2':

user_dict = dict() # 清空购物车

judge = 4 # 跳出功能选择

a = '0' # 继续购买

elif jump == '3':

user_dict = dict()

judge = 4 # 跳出功能选择

print("-" * 50)

print('欢迎下次光临')

elif jump == '0':

judge = 4 # 跳出功能选择

print("-" * 50)

print(f'一共{total_prices}元请到前台支付,如果有会员在下面输入会员信息')

print("-" * 50)

print('欢迎下次光临')

return shopping

#会员积分查询

if action == 3:

def menber_integral():

#生成总积分字典和用户信息字典:

menber_integral_dict = dict()

with open('用户注册信息.txt', 'a+', encoding='utf8') as fr_1:

fr_1.seek(0)

data = fr_1.read()

if data == '':

print('用户未注册请输入0去注册')

return

with open('会员积分.txt','a+',encoding='utf8') as fr:

fr.seek(0)

info_list = fr.read().split('|')[:-1]

for info in info_list:

info = info.split(':')

if info[0] not in menber_integral_dict:

menber_integral_dict[info[0]] = float(info[1])

else:

menber_integral_dict[info[0]] += float(info[1])

user_menber_integral_dict = dict()

with open('用户注册信息.txt','a+',encoding='utf8') as fr:

fr.seek(0)

user_info_list = fr.read().split('|')[:-1]

for user_info in user_info_list:

user_info = user_info.split(':')

user_menber_integral_dict[user_info[0]] = user_info[1]

# 生成剩余积分字典:

new_menber_integral_dict = dict()

with open('会员积分剩余积分.txt', 'a+', encoding='utf8') as fr:

fr.seek(0)

new_info_list = fr.read().split('|')[:-1]

for new_info in new_info_list:

new_info = new_info.split(':')

if new_info[0] not in new_menber_integral_dict:

new_menber_integral_dict[new_info[0]] = float(new_info[1])

else:

new_menber_integral_dict[new_info[0]] += float(new_info[1])

while True :

print('-'*50)

name = input('请输入你会员卡的名字(退出输入我忘了)').strip()

if name == '我忘了':

print('-' * 50)

print('请选择')

break

if not name in user_menber_integral_dict:

print('-' * 50)

print('会员账号输入错误')

print('-' * 50)

if name in user_menber_integral_dict and menber_integral_dict == dict():

print('你的积分为0分')

return

if name in menber_integral_dict:

print('-' * 50)

print('会员介绍'.center(46,' '))

print('积分小于10分为普通会员可以打9折\n'

'积分大于10分小于100分为黄金会员可以打8.5折\n'

'积分大于100分为黄金会员可以打8折')

print('-' * 50)

print(f'会员卡账号:{name}')

if menber_integral_dict[name] <10:

print('您当前会员等级为普通会员\n'

'您可以享受9折优惠')

elif menber_integral_dict[name] <100:

print('您当前会员等级为黄金会员\n'

'您可以享受8.5折优惠')

else:

print('您当前会员等级为至尊会员\n'

'您可以享受8折优惠')

print(f'当前总积分:{menber_integral_dict[name]}分')

print(f'已使用积分:{-new_menber_integral_dict[name] + menber_integral_dict[name]}分')

print(f'剩余积分:{new_menber_integral_dict[name]}分')

break

return menber_integral

#会员积分兑换系统

if action == 4:

def gift():

count = 0

# 生成剩余积分字典:

with open('用户注册信息.txt', 'a+', encoding='utf8') as fr_1:

fr_1.seek(0)

data = fr_1.read()

if data == '':

print('用户未注册')

return

new_menber_integral_dict = dict()

with open('会员积分剩余积分.txt', 'a+', encoding='utf8') as fr:

fr.seek(0)

new_info_list = fr.read().split('|')[:-1]

for new_info in new_info_list:

new_info = new_info.split(':')

if new_info[0] not in new_menber_integral_dict:

new_menber_integral_dict[new_info[0]] = float(new_info[1])

else:

new_menber_integral_dict[new_info[0]] += float(new_info[1])

#礼物字典:

gift_dict = {

'0':['钢笔',1.0],

'1':['奥特曼玩偶',2.0],

'2':['高达',10.0],

'3':['钢铁侠1比1外套',100.0]

}

#账号登入

#生成账号字典

user_dict = dict()

import os

if not os.path.exists('用户注册信息.txt'):

with open('用户注册信息.txt', 'x', encoding='utf8') as f:

pass

with open('用户注册信息.txt','r',encoding='utf8') as fr:

user_info = fr.read()

user_info_list = user_info.split('|')[:-1]

for user_pwd in user_info_list:

user_pwd = user_pwd.split(':')

user_name = user_pwd[0]

user_pwd = user_pwd[1]

user_dict[user_name] = user_pwd #注册时候用户名肯定不同所以不需要判断

#开始登入,生成用户信息内容为密码和姓名都是字符串格式

while count == 0:

name = input('输入账号名字(输入我忘了退出会员积分兑换)')

pwd = input('输入账号密码')

if name =='我忘了':

break

if name not in user_dict:

print('账号错误')

elif pwd != user_dict[name]:

print('密码错误')

else:

print('登入成功')

#打印他剩余积分以及奖品兑换信息

print('-'*50)

print('可兑换的奖品'.center(50,' '))

print(f"输入0礼品为{gift_dict['0'][0]}需要积分为{gift_dict['0'][1]}分\n"

f"输入1礼品为{gift_dict['1'][0]}需要积分为{gift_dict['0'][1]}分\n"

f"输入2礼品为{gift_dict['2'][0]}需要积分为{gift_dict['2'][1]}分\n"

f"输入3礼品为{gift_dict['3'][0]}需要积分为{gift_dict['3'][1]}分\n"

f"退出输入X或者x")

# print(gift_dict)

# print(new_menber_integral_dict)

print('-' * 50)

#选择礼物

while True:

gift_choise = input('请输入你要兑换的礼物').strip()

if new_menber_integral_dict == dict():

print('你的积分为0分')

return

elif gift_choise not in gift_dict:

print('请在0,1,2,3,X,x中选择输入')

continue

else:

if gift_choise == 'X' or gift_choise == 'x':

break

if name not in new_menber_integral_dict:

print('你的账号没有积分')

break

if gift_dict[gift_choise][1] > new_menber_integral_dict[name]:

print(f'积分不足\n'

f'您的剩余积分:{new_menber_integral_dict[name]}分')

else:

print(f"恭喜你获得{gift_dict[gift_choise][0]}\n"

f"剩余积分{new_menber_integral_dict[name]-gift_dict[gift_choise][1]}\n")

#将内容剩余积分进行统计

with open('会员积分剩余积分.txt','a',encoding='utf8') as fw:

fw.write(f'{name}:-{gift_dict[gift_choise][1]}|')

count = 1

break

return gift

print("-" * 50)

print('欢迎来到杨大爷超市'.center(30,' '))

print("-" * 50)

x = 0

while x == 0:

print('-' * 50)

your_chiose = input('输入0注册会员进入注册功能\n'

'输入1黑店我要走了\n'

'输入2直接进入购物\n'

'输入3会员积分查询\n'

'输入4会员积分兑换礼物\n'

'请输入:')

print('-' * 50)

if your_chiose not in ['0', '2', '1','3','4']:

print('亲,输入0~4中数字')

continue

else:

if your_chiose == '0':

chiose(0)()

elif your_chiose == '2':

chiose(2)()

chiose(1)()

elif your_chiose == '3':

chiose(3)()

elif your_chiose == '4':

chiose(4)()

else:

print('拜拜')

x = 1

三.鱼骨图分析异常

我用我之前工作,qc\qa工程师的经验给你们用鱼骨图分析法分析下我程序编写可能会碰到的异常情况

制图来之与X-Mind制作

先给大家简单介绍下鱼骨图分析方法.

首先是鱼骨,是我们要实现的一个某个功能,在工厂里呢这个叫工艺

第二步,大鱼刺我们就要画他的子功能,在工厂里是一个个工艺流程

第三步,小鱼刺是我们在实施子程序碰到的问题,在工厂是工艺流程中的一个个异常

然后我们要把一个个小鱼刺给解决掉,每次发现小功能异常就加小鱼刺,每次解决掉一个就拔去一个个小鱼刺,直到最后没有鱼刺为止.然后功能就慢慢完善了这是我在写我的小程序中碰到的问题

鱼骨图法是来分析异常解决异常的一种分析方法

python 鱼骨图_面向对象编程,鱼骨图分析法相关推荐

  1. python 鱼骨图_python面向对象编程,鱼骨图分析法

    一.面向对象编程 ​ 面向过程编程,核心是编程二字,过程指的是解决问题的步骤,即先干什么.后干什么.再干什么.然后干什么-- 与工厂的工艺流程差不多,前后都有影响 优点:复杂的问题流程化,进而简单化, ...

  2. 【设计模式从青铜到王者】第二篇:UML类图与面向对象编程

    系列文章目录 文章目录 系列文章目录 前言 一.设计概念 二.对象和类 三.类层次结构 四.面向对象程序设计基础概念 1.抽象 2.封装 3.继承 4.多态 5.对象之间的关系 总结 前言 一.设计概 ...

  3. python_绘制玫瑰图_南丁格尔图

    python_绘制玫瑰图_南丁格尔图 通过加载execel文件绘制 通过直接造数看这: https://blog.csdn.net/kaikai_sk/article/details/10495430 ...

  4. 基于STM32F103移植华为LiteOS_任务挂起与恢复_面向对象编程思想之按键状态机

    华为LiteOS_任务挂起与恢复_面向对象编程思想之按键状态机 因为在做华为LiteOS任务挂起和恢复需要使用到按键去触发任务挂起和恢复动作,因为我就萌发出使用状态机这种架构做一个按键检测触发.回想已 ...

  5. Java_第08章_面向对象编程(高级)

    第08章_面向对象编程(高级) 本章专题与脉络 1. 关键字:static 回顾类中的实例变量(即非static的成员变量) class Circle{private double radius;pu ...

  6. 图形化编程与python的区别_计算机编程启蒙为什么要选图形化编程和python

    以前人们学习计算机编程,大多是从敲代码开始的.因为上大学之前大多没有接触过计算机,打字速度很慢,计算机课时又比较少,每节课基本上都是敲完程序代码就下课了.课程没什么趣味,所以对计算机编程大多是比较抵触 ...

  7. python工作流引擎_工作流,活动图和Python协程(一)

    UML里面大家用得最多的是类图和序列图,比较少用到活动图(activity diagram).其实活动图在某些业务场景下也是简单实用的,它相比常规的流程图主要就多一个fork/merge原语,可以说是 ...

  8. python的面向对象编程学生成绩_python的类_面向对象编程

    摘自谬雪峰https://www.liaoxuefeng.com/wiki/1016959663602400/1017496031185408 面向对象编程(定义对象)和面向过程(定义函数)的区别,各 ...

  9. python编程求导数_面向对象编程 —— java实现函数求导

    首先声明一点,本文主要介绍的是面向对象(OO)的思想,顺便谈下函数式编程,而不是教你如何准确地.科学地用java求出函数在一点的导数. 一.引子 defd(f) :defcalc(x) : dx= 0 ...

最新文章

  1. 荐读 | 9篇近期社会化推荐论文
  2. pygame (1) 移动小乌龟
  3. 基于WINCE6.0+S3C6410的背光驱动
  4. PyTorch 实现经典模型5:ResNet
  5. Twitch 沈悦时:国内外互联网直播生态差异
  6. Loadrunner-web资源相关图表
  7. java中多线程 - 多线程中的基本方法
  8. mysql查询自定义数据_实现自定义查询的数据库设计及实现(一)
  9. Python装饰器几个有用又好玩的例子
  10. 图像变换--灰度切割、位图切割
  11. jQuery Hello世界
  12. Centos6.5优化Tomcat7
  13. 解决在编程方式下无法访问Spark Master问题
  14. 广告传媒实际税负怎么计算_增值税的理论税负和实际计算公式
  15. 品牌笔记本主板刷BIOS升级NVME ssd启动系统
  16. ps界面为啥突然变大了_PS教程丨皮肤美白修饰
  17. Android Studio实现一个校园图书管理系统
  18. 天镜漏洞扫描报告HTML转Excel格式Python脚本
  19. iframe内嵌标签
  20. 【雷达书籍推荐】 第2期 雷达原理

热门文章

  1. windows下搭建OpenGL ES开发环境
  2. 文本模式下安装Oracle 10g
  3. UIButton的几种触发方式
  4. SpringCloud 微服务 (十五) 服务容错 Hystrix
  5. dubbo之分组聚合
  6. mysql 基础操作一
  7. 【Android XMPP】 学习资料收集贴(持续更新)
  8. 关于CAS服务器磁盘占用的问题,锁定目录惹的祸
  9. 天天动听 半透明Menu效果
  10. 面试中几个基本的重要问题总结