#include
#include
#include
#include
#include
#include
classPlaying_Card
{
private:
intm_Value;
charm_Face[3];
charm_Suit;
public:
Playing_Card();
voidshowcard();
voidCard_Make(int);
};
classDeck
{
private:
Playing_Cardm_cardarray[54];
intm_lastdelt;
public:
Deck();
voidMakeDeck();
voidDeal_One();
voidShowDeck();
voidDeckShuff(int);
voidRemove_Card();
voidSenddeck();
};
voidProgram_Init();
intmain();
voidCenter_Text(char[]);
intget_number();
charGet_Key();
voidDeckMakeDriver();
intgetRandInt(intmin,intmax);
voidprog_clo();
intmain()
{
srand((unsigned)time(NULL));
intCard_Number=0;
Program_Init();
DeckMakeDriver();
prog_clo();//退出
return1;
}
Playing_Card::Playing_Card()
{
inti;
for(i=1;i<=3;)
{
m_Face[i]='';
i++;
}
m_Suit='';
m_Value=0;
}
//*******************************************************************
voidProgram_Init()//显示初始界面
{
Center_Text("C++课程设计实验报告");
cout<
Center_Text("扑克牌相关");
cout<
Center_Text("设计:郇志伟");
cout<
Center_Text("2006-9-20");
cout<
Center_Text("Hitthe
();
}
//*******************************************************************
charGet_Key()
{
charx;
x=();
cout<
returnx;
}
voidPlaying_Card::showcard()
{
cout<<"";
cout<
(1);
cout<
cout<<"";
}
//*******************************************************************
voidCenter_Text(charShellText[80])
{
intlength;
intcenter;
length=strlen(ShellText);
center=(80-length)/2;
for(;center!=0;center--)
{
cputs("");
}
cputs(ShellText);
}
intget_number()
{
intInput_Integer=活着摘抄 0;
Center_Text("Pleaenteranintegerbetween0and53.54toquit.");
cout<
cin>>Input_Integer;
returnInput_Integer;
}
//*******************************************************************
voidPlaying_Card::Card_Make(intnum)
{
inti=0;
charj;
if(num==53)
{
strcpy(m_Face,"jo");
m_Suit='2';
m_Value=15;
}
if(num==52)
{
strcpy(m_Face,"jo");
m_Suit=打工族 '1';
m_Value=14;
}
if(num<=51)
{
intface_num=num%13;
switch(face_num)
{
ca0:strcpy(m_Face,"A");break;
ca9:strcpy(m_Face,"10");break;
ca10:strcpy(m_Face,"J");break;
ca11:strcpy(m_Face,"Q");break;
ca12:strcpy(m_Face,"K");break;
default:
j=char(face_num+49);
if(i<3)
{
m_Face[i]='';i++;
m_Face[i]=j;i++;
m_Face[i]=NULL;
break;
}
}
if(num<=12)m_Suit=6;
if(num>12&&num<=25)m_Suit=3;
if(num>25&&num<=38)m_Suit=5;
if(num>38&&num<=51)m_Suit=4;
if(face_num<=9)m_Value=face_num+1;
if(face_num>=10)m_Value=10;
}
}
//*******************************************************************
voidDeckMakeDriver()
{
Deckdeck_1;
deck_ck();//创建一副扑克
deck_ck();//显示一副扑克
Get_Key();
deck_uff(250);//洗牌
deck_ck();//显示一副扑克
Get_Key();
deck_ck();//依次分发给4个人并显示
Get_Key();
cout<
chary;
do
{
deck__One();//删除一张牌
cout<
cout<
cin>>y;
y=toupper(y);
}while(y=='Y');
}
//*******************************************************************
voidDeck::MakeDeck()//创建一副扑克
{
m_lastdelt=53;
while(m_lastdelt>-1)
{
m_cardarray[m_lastdelt].Card_Make(m_lastdelt);
m_lastdelt--;
}
}
//*******************************************************************
voidDeck::ShowDeck()//显示一副扑克
{
intindex=m_lastdelt+1;
intnewline=0;
Center_Text("CurrentDeckofCardsfromtoptobottom");
cout<
while(index<=53)
{
if(new材料的英语
line%11==0)cout<
m_cardarray[index].showcard();
newline++;
index++;
}
cout<
}
//*******************************************************************
intgetRandInt(intmin,intmax)
{
intnumToReturn;
numToReturn=rand();
numToReturn=numToReturn%(max-min+1)+min;
returnnumToReturn;
}
//*******************************************************************
voidDeck::DeckShuff(inttimes)//洗牌
{
intx,split;
Center_Text("ShufflingDeck");
cout<
for(x=0;x<=times;x++)
{
split=getRandInt(20,35);
Decktopdeck;
Deckbottomdeck;
inti;
intbottomdeckindex=1;
inttopdeckindex=1;
for(i=0;i<=split-1;)
{
topdeck.m_cardarray[topdeckindex]=this->m_cardarray[i];
topdeckindex++;
i++;
}
for(i=(split);i<54;)
{
bottomdeck.m_cardarray[bottomdeckindex]=this->m_cardarray[i];
bottomdeckindex++;
i++;
}
intdeckoutindex=0;
intnumcardstomovetop;
intnumcardstomovebottom;
intj;
inth=0;
bottomdeckindex=54-split;
topdeckindex=split;
while(deckoutindex<=53)
{
numcardstomovetop=getRandInt(2,7);
numcardstomovebottom=getRandInt(2,7);
for(j=0;j<=numcardstomovebottom;j++)
{
if(bottomdeckindex>0)
{
this->m_cardarray[deckoutindex]=bottomdeck.m_cardarray[bottomdeckindex];
deckoutindex++;
bottomdeckindex--;
}
for(h=0;h<=numcardstomovetop;h++)
{
if((topdeckindex>0)&&(deckoutindex<=54))
{
this->m_cardar鲍的读音 ray[deckoutindex]=topdeck.m_cardarray[topdeckindex];
deckoutindex++;
topdeckindex--;
}
}我的一个道姑朋友歌词
}
}
}
this->m_lastdelt=-1;
}
//*******************************************************************
voidDeck::Senddeck()//依次分发给4个人并显示
{
intm_player,n_player;
intplayer1=0,player2=0,player3=0,player4=0;
this->m_lastdelt=53;
Playing_Cardplayeri[2][14];
Playing_Cardplayerj[2][13];
inttime=0;
while(time<13)
{
m_player=0,n_player=0;
playeri[m_player][player1]=this->m_cardarray[m_lastdelt];
m_player++;player1++;m_lastdelt--;
playeri[m_player][player2]=this->m_cardarray[m_lastdelt];
player2++;m_lastdelt--;
playerj[属猪和属鼠的婚姻怎么样 n_player][player3]=this->m_cardarray[m_lastdelt];
n_player++;player3++;m_lastdelt--;
playerj[n_player][player4]=this->m_cardarray[m_lastdelt];
player4++;m_lastdelt--;
time++;
}
playeri[0][13]=this->m_cardarray[1];
playeri[1][13]=this->m_cardarray[0];
for(inti=0;i<=3;i++)
{
cout<<"player"<
if(i<=1)
{
for(intj=0;j<=13;j++)
{
playeri[i][j].showcard();
}
}
el
{
for(intj=0;j<=12;j++)
{
playerj[i-2][j].showcard();
}
}
cout<<'n';
}
}
//*******************************************************************
voidprog_clo()//退出
{
cout<
cout<<"Hitthe
cout<
Get_Key();
();
}
//*******************************************************************
voidDeck::Remove_Card()//删除一张牌。
{
m_cardarray[m_lastdelt]=Playing_Card();
}
intk=53,j=0;
//*******************************************************************
voidDeck::Deal_One()
{
j++;
inti=0;
intcardnum1,cardnum2;
intnum=1;
if(k<0)
cout<<"OutofrangeError";
el
{
m_lastdelt=getRandInt(0,k);
cardnum1=m_lastdelt;
cardnum2=m_lastdelt;
Deckdeck1;
cout<<"carddelt";
m_cardarray[m_lastdelt].showcard();
cout<<'n';
cardnum2++;
while(cardnum2<54)
{
deck1.m_cardarray[i]=this->m_cardarray[cardnum2];
i++;cardnum2++;
}
i=0;
while(cardnum1+j<54)
{
this->m_cardarray[cardnum1]=deck1.m_cardarray[i];
cardnum1++;i++;
}
i=0;
cout<<"cardleft"<<'n';
while(i+j<54)
{
this->m_cardarray[i].showcard();
if(num%11==0)cout<<'n';
num++;i++;
}
}
k--;
}
//*******************************************************************
Deck::Deck()
{
intlastdelt=0;
inti;
for(i=0;i<=53;i++)
{
m_cardarray[1]=Playing_Card();
}
}
本文发布于:2023-03-23 14:40:12,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/57aa7f12c396b7e9dd30619e67f86998.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:游戏扑克牌.doc
本文 PDF 下载地址:游戏扑克牌.pdf
留言与评论(共有 0 条评论) |