C课程设计点纸牌游戏程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{
cout<<endl;
cout<<"\t\t\t庄家得到一张牌!"<<endl;
();<<endl;
cout<<"如果您是高级玩家或超级玩家请按y."<<endl;
cin>>ans;
label1:if(ans=='y'||ans=='Y')
{
(20,'\n');//把输入行中的其余字符取空,以便后面的输入从新一路轮开始
cout<<"请输入特别玩家的6位密码:";
(s1,7);//提取密码
if(!strcmp(s1,answer))
{
cout<<"\t\t\t这张牌是:"<<copycard<<endl;
cout<<"是否加注(y or n)\n";
cin>>ans;
if(ans=='y'||ans=='Y')
{
cout<<"你的现金还有$"<<money<<endl;
void Game::clean()//清零
{
win=this->win,lose=this->lose,draw=this->draw,playerturns=0,cputurns=0,money=this->money,
bet=0,player=0,cpu=0;
}
//---------------------------------------------------------------------
copycard=card;
cout<<"这张牌是:"<<card;
if(card>10)
{
cards=,card=0;
};
cpu=cpu+cards+card;
if(cpu>21){
if(cards==0)cpu-=copycard;//当card小于10但总数大于21时执行
else cpu-=cards; //当card大于10且点数大于21时执行
}
}
//-----------------------------------------------------------------
void Game::hit2()//确保庄家不会爆庄并且点数大于16
{
int card=0,copycard=0;
float cards=0;
card=random(13,1);//调用函数
cout<<"您要的牌为"<<"["<<card<<"]"<<endl;
player=player+card;//牌点总数
cout<<"总的牌面是:"<< player<<endl;//输出总点数
cout<<endl;
}
else
{
cout<<"对不起,你输入的密码错误!不能看牌"<<endl;
cout<<"是否再次输入密码(yes or no)"<<endl;
void Game::replay(char &ans)//是否继续游戏
{
cout<<"\n\t\t\t你是否想继续游戏(yes or no)";
cin>>ans;
}
//---------------------------------------------------------------------
player=0,cpu=0;
char answer1[]="123456";
strcpy(answer,answer1);
char answer2[]="654321";
strcpy(daan,answer2);
};
void rules();...."<<endl;
wait(500);
playercard2=random(13,1);
void Game::results()//找出赢家
{
if(cpu==player)
{
cout<<"\t\t\t点数一样,你们平了!"<<endl;
draw++;
money+=bet;
}
if(player>21)
{
cout<<"\t\t\t啊哦,你爆了!:("<<endl;
lose++;
}
else
{
win++;
money=money+(bet*2);
}
}
else
{
if(cpu>player)
{
cout<<"\t\t\t不好意思,你输了!:("<<endl;
lose++;
}
}
}
//---------------------------------------------------------------------
C课程设计点纸牌游戏程序
#include<>
#include<>
#include<>
#include<>
#include<>
#include<>
class Game
{
public:
Game()
{
win=0,lose=0,draw=0,playerturns=0,cputurns=0,money=100,bet=0;
if(cpu<player)
{
cout<<"\n\t\t\t恭喜你,你赢了!:)";
money=money+(bet*2);
win++;
}
}
if(cpu>21)
{
cout<<"\t\t\t恭喜你,庄家爆了!:)"<<endl;
if(player<21)
{
cout<<"\n\t\t\t恭喜你,你赢了!:) ";
cin>>ans;
if(ans=='y'||ans=='Y')
goto label1;
else
{
cout<<"\t\Hale Waihona Puke Baidu\t总点数是:"<<player<<endl;
}
}
}
}
else
{
if(card>10)
{
cards=,card=0;
};
player+=cards+card;
cout<<"\t\t\t总点数为:"<<player<<endl;
void Game::check()
{
if(money<=0) //检查钱的多少
{
cout<<"对不起,你输光了,你不能玩了!:("<<endl; //sees if your broke
}
}
//---------------------------------------------------------------------
else player-=copycard;
cout<<"\t\t\t你的总点数为:"<<player<<endl;
}
}
else
{
if(strcmp(s1,daan)==0)
{
cout<<endl;
cout<<"现在计算机的总牌点为:"<<cpu<<endl;
cout<<"您的总牌点为:"<<player<<endl;
cout<<"\t\t\t总点数为:"<<cpu<<endl;
}
if(cpu<16)//确保庄家点数大于等于16
{
cpu=16;
cout<<"\t\t\t总点数是:"<<cpu<<endl;
}
}
//---------------------------------------------------------------------
wait(500);
cout<<"["<<playercard1<<"]";
cout<<"["<<playercard2<<"]";
if(playercard1>10).){
cout<<"你的输入有误!:(请重新输入"<<endl;
m=2;
}
}while(m!=0);
if((ans=='h')||(ans=='H'))
Game Game::operator=(Game &d)//保留上一轮的一些数据
{
Game t;
+=,+=,=+,=0,=0,+=,=0,=0;
return t;
}
//---------------------------------------------------------------------
{
playerturns++;
if(playerturns>5)
{
cout<<"\t\t\t你不能多于5张牌!"<<endl;
}
}
if((playerturns<6)&&(ans=='h'))
{
cout<<endl;
();
}
}while((ans=='h')||(ans=='H'));
for(;(cpu<16)&&(cputurns<6);cputurns++)
float card;
card=(float)random(13,1);
if(card>10) card=;
cout<<"下张牌面是:"<<"["<<card<<"]"<<endl;
cout<<"您想要什么牌请输入牌点数:";
cin>>card;
if(card>10) card=;
cout<<endl;
cout<<"你要加多少注(你也可以不加)";
cin>>bet1;
if(money-bet1<0)
{
cout<<"你没有足够的赌注";
}
money=money-bet1;
bet+=bet1;
cout<<"\t\t\t你的总点数为:"<<player<<endl;
}
else
{
if(cards==
player-=cards;
相关文档
最新文档