8面向对象编程技术实验指导教程[参.pdf

上传人:H****o 文档编号:56679953 上传时间:2022-11-02 格式:PDF 页数:20 大小:220.65KB
返回 下载 相关 举报
8面向对象编程技术实验指导教程[参.pdf_第1页
第1页 / 共20页
8面向对象编程技术实验指导教程[参.pdf_第2页
第2页 / 共20页
点击查看更多>>
资源描述

《8面向对象编程技术实验指导教程[参.pdf》由会员分享,可在线阅读,更多相关《8面向对象编程技术实验指导教程[参.pdf(20页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、面向对象编程技术实验指导教程郑州轻工业学院计算机与通信工程学院网络工程系目录1实验目的.32实验题目.33实验步骤.43.1需求.43.2设计.53.3编码.63.4测试.173.5系统升级.错误!未定义书签。4实验报告.185实验验收.186实验成绩.错误!未定义书签。附录 1 实验报告格式.19文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 Z

2、G9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9

3、B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 Z

4、G9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9

5、B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 Z

6、G9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9

7、B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9网络编程基础实训教程31 实验目的通过开发一款贪吃蛇游戏程序

8、,熟练掌握C#编程语言、和面向对象程序设计方法,独立完成一个游戏程序的开发。2 实验题目使用C#编程语言,开发一款贪吃蛇游戏,如下图所示。游戏基本功能描述如下:1)游戏场地是一片矩形区域的草坪。文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编

9、码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H

10、1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编

11、码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H

12、1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编

13、码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H

14、1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9网络编程基础实训教程42)一条蛇由蛇头和蛇身组成。3)当游戏开始之后,草坪中出现一颗豆和一条蛇,并且蛇不停地移动,蛇移动的方向与蛇头的方向一致。4)当蛇移动时,玩家使

15、用“”、“”、“”和“”四个键控制蛇的方向。5)当蛇头与豆的位置重合时,豆被蛇吃掉,同时在草坪中再生成一颗新的豆,蛇身增加一节。6)当蛇头碰到草坪四周或蛇身时,蛇立即毙命,游戏结束。3 实验步骤3.1 需求根据功能描述可知,贪吃蛇游戏的系统结构图如下所示。定义数据字典如下:1)草坪(Lawn):草坪是贪吃蛇游戏的场地。豆和蛇只能存在于草坪范围之内。草坪具有大小和颜色等属性。2)蛇(Snake):在贪吃蛇游戏中,蛇由若干节组成,其中第一节是蛇头,其余是蛇身。在游戏过程中,有且仅有一条文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2

16、HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S

17、5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2

18、HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S

19、5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2

20、HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S

21、5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2

22、HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9网络编程基础实训教程5蛇,并且蛇在不停地移动。如果蛇吃了豆,则蛇生长一节。如果蛇头碰到蛇身或离开草坪,则蛇死亡游戏结束。蛇具有长度、颜色、运动方向、每一节的位置等属性。3)豆(Bean):在贪吃蛇游戏中,豆是蛇的食物。在游戏过程中,有且仅有一颗豆。如果蛇吃了豆,则重新生成一颗豆。豆具有位置、大小和颜色等属性。3.2 设计根据需求分析可知,Snake的每一节都有位置和大小等属性。而Bean也具有这两个属性。抽象出二者的共同特征,抽象出一般类Block,用于描述一个块。Bl

23、ock派生出 Bean和SnakeBlock两个类,其中SnakeBlock类用于描述蛇的一节。为了使游戏的运行更易于控制,定义Game类用于启动、暂停和继续游戏。根据需求分析可知,Lawn仅包含大小和颜色两个属性。为了减少类的数量,可将其大小和颜色等属性添加到Game类中。综上所述,在贪吃蛇游戏中,有Block(块)、Bean(豆)、SankeBlock(节)、Snake(蛇)、Game(游戏)和 MainForm(用户接口)六个类。贪吃蛇游戏的逻辑模型如下图所示。文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1

24、L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码

25、:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1

26、L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码

27、:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1

28、L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码

29、:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1

30、L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9网络编程基础实训教程6MainFormGameBlockBeanSnakeBlockSnake3.3 编码3.3.1 Block(块)类编码Block是用来构成 Bean(豆)和 Snake(蛇)的最基本的单位,是Bean和SnakeBlock的基类。Block类的参考代码如下。usingSystem;usingSystem.Drawing;namespace HungrySnakeclassBlockprotectedPointorigion;/Block 的左上顶点publicc

31、onstintWIDTH=10;/Block 的宽度publicconstintHEIGHT=10;/Block 的高度protectedColorcolor;/Block 的颜色publicBlock()origion=new Point(0,0);color=new Color();文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3

32、S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2

33、 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3

34、S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2

35、 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3

36、S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2

37、 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9网络编程基础实训教程7publicBlock(intx,inty,Col

38、or_color)origion=new Point(x,y);color=_color;publicPointOrigiongetreturnorigion;publicvoidDisplay(Graphicsg)SolidBrushbrush=new SolidBrush(color);g.FillRectangle(brush,origion.X,origion.Y,WIDTH,HEIGHT);Pen pen=new Pen(Color.Black);g.DrawRectangle(pen,new Rectangle(origion.X,origion.Y,WIDTH-1,HEIGHT-

39、1);publicvoidClear(Graphicsg,ColorbackGroundColor)SolidBrushbrush=new SolidBrush(backGroundColor);g.FillRectangle(brush,origion.X,origion.Y,WIDTH,HEIGHT);3.3.2 Bean(豆)类编码Bean表示豆,是由 Block派生而来的。Bean类的参考代码如下。usingSystem;usingSystem.Drawing;namespace HungrySnakeclassBean:BlockpublicBean(Color_color)orig

40、ion=new Point(0,0);color=_color;publicvoidCreat(Graphicsg,ColorbackGroundColor,intlawnWidth,int文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:

41、CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L

42、9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:

43、CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L

44、9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:

45、CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L

46、9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9网络编程基础实训教程8lawnHeight,Snake snake)Clear(g,backGroundColor);boolbGetAPosition=false;/是

47、否找到生成豆的位置Randomrandom=new Random();while(!bGetAPosition)origion.X=random.Next(0,lawnWidth-1)/WIDTH*WIDTH;origion.Y=random.Next(0,lawnHeight-1)/HEIGHT*HEIGHT;inti;for(i=0;i snake.Length;i+)if(origion=snake.blocksi.Origion)break;if(i=snake.Length)bGetAPosition=true;Display(g);3.3.3 SnakeBlock(节)类编码Sna

48、keBlock表示蛇的一节,是由 Block派生而来的。SnakeBlock类的参考代码如下:usingSystem;usingSystem.Drawing;namespace HungrySnakeclassSnakeBlock:BlockprivateboolisHead;publicboolIsHeadgetreturnisHead;publicSnakeBlock(intx,inty,Color_color,bool_isHead)文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5

49、I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 H

50、X4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5I9文档编码:CP6P9B6Z9O2 HX4P9H1L9J2 ZG9G4R3S5

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 高考资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁