面向对象课程设计

面向对象课程设计

ID:12889351

大小:381.50 KB

页数:10页

时间:2018-07-19

面向对象课程设计_第1页
面向对象课程设计_第2页
面向对象课程设计_第3页
面向对象课程设计_第4页
面向对象课程设计_第5页
资源描述:

《面向对象课程设计》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、本科课程设计报告《面向对象程序设计》院(系)专业信息与计算科学学生姓名学号22任课教师提交日期2011-1-301应用环境(1).操作系统:WindowsNT、WindowsXP、Windows7(2).应用软件:MicrosoftVisualStudio20052需求分析利用面向对象编程的知识和C#编程语言编写一个简单的拼图游戏。3可行性分析拼图游戏所需的运行界面简单,易操作,利用键盘的上下左右键能很容易操作,而且具有很强的技巧性,能锻炼我们的逻辑思维。程序设计概要设计目标及原理本游戏基于著名的数学问题“八数码”。这是人工智能里较著名的一个问题,在

2、3×3的方阵中有8个数码,刚开始时它们是随机无序排列的,并只剩下一个空格,空格可以在方阵中随意移动,要求通过有限次移动,使得数字方阵达到有序的状态。在人工智能里是通过某种搜索方法找到该问题的解,在这里通过用户自己的操作来移动达到游戏的目的。拼图游戏就是这个基础上改进的,将3×3扩大为4×4的方阵,并使每个方阵代表完整图片的一个小部分。用户如果能先拼好其他的7块图片那剩下来的问题就是排列3×3个方阵的问题程序功能模块登陆主界面1界面2退出关闭窗口程序详细设计界面1主要代码usingSystem;usingSystem.Collections.Gener

3、ic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;namespaceExercise{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();PlaceRandom();}privatevoidForm1_Load(objectsender,EventArgse){}privatevoidSwap(intvNu

4、m,intblank){Pointtemp;switch(vNum){case1:temp=label1.Location;label1.Location=label9.Location;label9.Location=temp;break;case2:temp=label2.Location;label2.Location=label9.Location;label9.Location=temp;break;case3:temp=label3.Location;label3.Location=label9.Location;label9.Locat

5、ion=temp;break;case4:temp=label4.Location;label4.Location=label9.Location;label9.Location=temp;break;case5:temp=label5.Location;label5.Location=label9.Location;label9.Location=temp;break;case6:temp=label6.Location;label6.Location=label9.Location;label9.Location=temp;break;case7

6、:temp=label7.Location;label7.Location=label9.Location;label9.Location=temp;break;case8:temp=label8.Location;label8.Location=label9.Location;label9.Location=temp;break;}}privatevoidForm1_KeyDown(objectsender,KeyEventArgse){inttemp;switch((int)e.KeyCode){case38://向上方向键if(ar<2){te

7、mp=pos[ar,ac];pos[ar,ac]=pos[ar+1,ac];pos[ar+1,ac]=temp;Swap(pos[ar,ac],temp);//交换空白格和下边的方格ar++;Hits++;}break;case37://向左方向键if(ac<2){temp=pos[ar,ac];pos[ar,ac]=pos[ar,ac+1];pos[ar,ac+1]=temp;Swap(pos[ar,ac],temp);//交换空白格和右边的方格ac++;Hits++;}break;case39://向右方向键if(ac>0){temp=pos[a

8、r,ac];pos[ar,ac]=pos[ar,ac-1];pos[ar,ac-1]=temp;Swap(p

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。