猜拳游戏(基于python面向对象2)
2017-08-19 13:04
309 查看
第2阶段
代码如下:
编写计算机类(Computer) 需求 1 属性有名字name , 积分 score 2 行为 出拳(showFist) 3 测试计算机出拳
代码如下:
import random #创建用户类 class Computer(): #构造函数 def __init__(self,name,score): self.name=name self.score= score # 出拳 def showFist(self): type = random.randint(1,3) if type==1: print(self.name,"出剪刀") elif type==2: print(self.name,"出石头") elif type==3: print(self.name,"出布") return type
相关文章推荐
- 猜拳游戏(基于python面向对象1)
- JavaScript基于面向对象实现的猜拳游戏
- 【Python之旅】第四篇(四):基于面向对象的模拟人生游戏类
- 猜拳游戏(基于python面向对象3)
- 基于Python实现的扫雷游戏实例代码
- [python 译] 基于面向对象的分析和设计
- 基于面向对象的模拟人生游戏类
- 用Robot Framework+python来测试基于socket通讯的C/S系统(网络游戏)
- 如何使用Python基于Pygame写一个简易的微信打飞机游戏。
- 猜拳游戏(基于python面向对象4)
- Python基于分水岭算法解决走迷宫游戏示例
- python--elif猜拳游戏
- 基于python的随机数游戏
- python笔记(猜拳游戏)
- 学习Python就业有哪些方向?附加视频教程(python3从入门到进阶(面向对象),实战(爬虫,飞机游戏,GUI)视频教程)
- Python基于pygame实现的font游戏字体(附源码)
- 基于Python的标准库tkinter创建面向对象的GUI应用程序
- C#面向对象基于winform的扫雷游戏和简单的算法改进
- 基于python的猜数字游戏
- python基于pygame实现响应游戏中事件的方法(附源码)