- 1、本文档共7页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
五子连珠(面向象设计)
五子连珠(面向对象设计)
摘要:根据面向对象的思想,进行类的封装与继承,运用C++语言完成五子连珠游戏的设计
一:编程思路:
首先编写棋盘类与棋子类,写好判断胜负的算法,运用派生与继承,想好是哪些类需要派生与继承
二:代码及分析:
#includeiostream
#includeconio.h
#include ctime
using namespace std; //所需头文件说明
const int high=12;
const int wide=22; //定义棋盘宽高
const char first=2;
const char second=4; //定义棋子形象
int x,y,t,flag;
char temp;
static int o,g; //后面所用到的其它变量声明
struct
{
int x,y;
}move[8]={0,1,1,1,1,0,1,-1,0,-1,-1,-1,-1,0,-1,1}; //做胜负判断所需的结构体
class QIPAN //棋盘类
{
private: int k,h;
public:
static char now[high][wide];
QIPAN() //欢迎界面
{
for(k=0;kwide;k++) coutnow[0][k];for(k=0;kwide;k++)coutnow[0][k];
coutendl;
coutI◤ ◥Iendl;
coutI ▃▃▃▃ ▃▃▃ ㊣ Iendl;
coutI ■ ■ Iendl;
coutI ▃■▃▃ ▃▃■▃▃ I endl;
coutI ■ ■ Iendl;
coutI ■■■■■■ ■■ Iendl;
coutI Iendl;
coutI Iendl;
coutI Iendl;
coutI Iendl;
coutI◣ ◢Iendl;
coutI Iendl;
coutI Iendl;
coutI Ver.1.0 Iendl;
for(h=0;hwide;h++)coutnow[high-1][h]; for(h=0;hwide;h++)coutnow[high-1][h];
coutendl;
coutendl;
cout 按任意键继续... ...endl;
while(!kbhit());// 函数名:kbhit()(VC++6.0下为_kbhit()) 功 能及返回值: 检查当前是否有键盘输入,若有则返回一个非0值,否则返回0 用 法:int kbhit(void); 包含头文件: include conio.h
getch();
system(cls);//清屏
for(k=0;kwide;k++) coutnow[0][k];for(k=0;kwide;k++) coutnow[0][k];
coutendl;
coutI 游戏说明 Iendl;
coutI 本游戏为试玩版本,主要用作学习交流,顺Iendl;
coutI 便制造点商机^ ^请于下载后24小时内自动自觉 Iendl;
coutI 删除,购买正版请到一公寓410宿舍~听说女的 Iendl;
coutI 还有折打
文档评论(0)