模拟21点扑克牌游戏(C++课设)(2)
void Game::Draw()//平局 { nDraw++;
nMoney+=nGamble; cout<<"平局牌面"<<endl; DisplayPip(); if(GetPip()>21) cout<<"暴了!"<<endl; else
cout<<"牌面点数:"<<GetPip()<<endl;
cout<<"赌本:$"<<nMoney<<" 赢了"<<nWin<<"次 "<<"输了" <<nLose<<"次 "<<"平局"<<nDraw<<"次 "<<endl; cout<<"\n\n\n"; }
void Game::DisplayPip(int n)//除了除了前两张牌,一次全部显示牌面点数(针对计算机牌的显示) {
cout<<"[*]"<<"\t"; cout<<"[*]"<<"\t";
for(int i=2;i<nNumber;i++) cout<<naPip[i]<<"\t"; cout<<endl; }
void Game::error1(char a)// {
do{
cin>>a;
if((a=='y')||(a=='Y')||(a=='N')||(a=='n'))
goto sta;
cout<<"请确定你输入的"<<a<<"是否为“Y/N”。否则请重新输入“Y/N”"<<endl;
}while(cin.good());
}
void Game::error2(int a)// { do {
while(cin.fail()) {
cout<<"你输入的赌金必须为正整数。否则请重新输入:"<<endl; cin.clear();
cin.ignore(1024,'\n'); cin>>a; } cin>>a; sta: chChoice=a;
}while(a<0); nDallor=a; }
void Game::addGamble()//增加赌注 { }
void Game::Judge()// {
cout<<endl;
if((cpu.GetPip()>21&&player.GetPip()>21)||cpu.GetPip()==player.GetPip()) {
cout<<"\n\n平局\n!"; cout<<"\t\t计算机数据:\t"; cpu.DisplayPip();
cout<<"牌面点数:"<<cpu.GetPip()<<endl;
int a;
player.error1(chChoice);
if(chChoice=='y'||chChoice=='Y') { }
player.cls();
cout<<"\n\n\n\n\t你还有赌本:\t"<<player.getMoney()<<endl; cout<<"\t请输入增加的赌金:\t"; do {
player.error2(nDallor); a=player.setGamble(nDallor); }while(a);
cout<<"\n\t\t您的数据\t"; player.Draw(); cout<<endl; }
else if((cpu.GetPip()>21||(player.GetPip())>cpu.GetPip()&&player.GetPip()<=21)) {
cout<<"\n\n恭喜您,您赢了\n!"; cout<<"\t\t计算机数据:\t"; cpu.DisplayPip();
cout<<"牌面点数:"<<cpu.GetPip()<<endl; cout<<"\n\t\t您的数据\t"; player.Win(); cout<<endl; } else {
cout<<"\n\n很遗憾,您输了\n!"; cout<<"\t\t计算机数据:\t"; cpu.DisplayPip();
cout<<"牌面点数:"<<cpu.GetPip()<<endl; cout<<"\n\t\t您的数据\t"; player.Lose(); cout<<endl; } }
void Game::cls()// {
cout<<"请输入任意键继续"<<endl; getchar(); system("cls"); }
void Game::playTurn()// {
int blCpu=1,blPlayer=1; cpu.FirstPlayTwo(); do {
player.TurnPlay();
cout<<"\t您要的这张牌,牌点是\t"<<player.GetCurrentCard()<<endl; cout<<"您的牌点为:\t"<<endl; player.DisplayPip();
cout<<"计算机的牌点为"<<endl; cpu.DisplayPip(1);
cout<<"您的牌面点数是"<<player.GetPip()<<endl; cout<<"\n\t您一共下注:"<<nGamble;
cout<<"\n请问是否要增加赌注,输入“Y”增加,输入“N”不增加"<<endl; player.addGamble(); if(blPlayer) { { {
cpu.TurnPlay();
cout<<"\t计算机要牌,牌点是:\t"<<cpu.GetCurrentCard()<<endl; blCpu=0; } }
} else blCpu=0;
if(cpu.GetPip()<18&&cpu.GetNumber()<5) if(nNumber>5) { }
cout<<"\n\n\n\t您是否继续要牌?(Y/N)"<<endl; player.error1(chChoice); system("cls");
if((chChoice=='Y'||chChoice=='y')) { } else { }
cout<<"\n\t你放弃了该轮抽牌"; nNumber--;blCpu=1; if(nNumber>2) { }
cout<<"\n\t\t你的点数爆了哦~"<<endl; blPlayer=0;blCpu=0; blCpu=1; blCpu=0; else
if(player.GetPip()>21) blPlayer=0; else
while(blCpu)
}while((blCpu)||(blPlayer)); player.Judge(); Sleep(2000); game.StoreUser(); }
void Game::showCpu()// { }
int Game::Movegame()// {
srand((unsigned)time(NULL));
cout<<"\n\n\n\t\t\t是否开始游戏 (Y/N)?\n"; player.error1(chChoice);
while(chChoice=='Y'||chChoice=='y') { do {
cout<<"您现在有的赌本:"<<player.getMoney()<<endl; cout<<"请下注:(赌注不能超过赌本)"<<endl; player.error2(nDallor);
blLogic=player.setGamble(nDallor); }while(blLogic);
player.playTurn(); //玩一局 player.cls();
player.DisplayInfo();//显示赌完之后的结果。 cout<<"\n\n\n\t\t\t是否继续玩游戏(Y/N)"<<endl; player.error1(chChoice); nNumber=0;//开始没有发牌 for(int i=0;i<5;i++) naPip[i]=0; //五张牌全部为0 nGamble=0; nPip=0; system("cls"); } }
Display::Display()// {
game.Begin(); return 0; temp=nNumber; nNumber=2; cpu.DisplayPip(); nNumber=temp;
}
int Display::nMoney()// {return Money;}
void Display::DisplayMenu()//0.进入运行菜单界面 {
cout<<"\n\n\t\t∷∷∷∷∷∷∷∷∷∷∷∷∷∷∷∷∷∷∷∷∷∷∷\n"; cout<<"\t\t∷ ∷\n"; cout<<"\t\t∷ ∷\n"; cout<<"\t\t∷ ∷\n"; cout<<"\t\t∷━━━━>欢迎进入21点游戏世界!<━━━━∷\n"; cout<<"\t\t∷ ∷\n"; cout<<"\t\t∷ …… 此处隐藏:2371字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [小学教育]四年级综合实践活动课《衣物的洗涤》教
- [小学教育]2014半年工作总结怎么写
- [小学教育]20世纪外国文学专题综合试题及答案
- [小学教育]TS_1循环使用催化丙烯环氧化反应研究
- [小学教育]最实用的考勤签到表(上下班签到表)
- [小学教育]气候与生态建筑——以新疆民居为例
- [小学教育]二人以上股东有限责任公司章程参考样本
- [小学教育]2014届第一轮复习资料4.1,3美好生活的
- [小学教育]土方开挖、降水方案
- [小学教育]手绘儿童绘本《秋天的图画》(蜡笔)
- [小学教育]2002级硕士研究生卫生统计学考试试题
- [小学教育]环保装备重点发展目录
- [小学教育]金蝶K3合并报表培训教材
- [小学教育]岩浆岩试题及参考答案
- [小学教育]知之深爱之切学习心得
- [小学教育]第十二章 蛋白质的生物合成
- [小学教育]Chapter 2-3 Solid structure and basi
- [小学教育]市政道路雨季专项施工方案
- [小学教育]中国海洋大学2012-2013学年第二学期天
- [小学教育]教育心理学第3章-学习迁移
- 浅谈深化国企改革中加强党管企业
- 2006年中国病理生理学会学术活动安排
- 设计投标工作大纲
- 基于ARP的网络攻击与防御
- 2016届湖北省七市(州)教科研协作体高三
- Google_学术搜索及其检索技巧
- 2019-2020学年七年级地理下册6.3美洲教
- 城市道路可研报告
- 【名师指津】2012高考英语 写作基础技
- 6级知识点培训北京师范大学《幼儿智趣
- 注册会计师会计知识点:金融资产
- 新安装 500 kV 变压器介损分析与判断
- PS2模拟器PCSX2设置及使用教程.
- 医院药事管理与药剂科管理组织机构
- {PPT背景素材}丹巴的醉人美景,免费,一
- NAS网络存储应用解决方案
- 青海省西宁市六年级上学期数学期末考试
- 测量管理体系手册依据ISO10012:2003
- 洞子小学培养骨干教师工作计划
- 浅谈《牛津初中英语》的教材特点及教学




