<form id="dlljd"></form>
        <address id="dlljd"><address id="dlljd"><listing id="dlljd"></listing></address></address>

        <em id="dlljd"><form id="dlljd"></form></em>

          <address id="dlljd"></address>
            <noframes id="dlljd">

              聯系我們 - 廣告服務 - 聯系電話:
              您的當前位置: > 關注 > > 正文

              世界實時:C++撲克牌類的設計 C++撲克牌類怎么設計?

              來源:CSDN 時間:2022-12-21 19:03:50


              (資料圖片僅供參考)

              C++撲克牌

              1、設計撲克類Card:主要屬性有花色和點數;主要方法有初始化、輸出、比較大小等 2、設計一副撲克牌類Cards:主要屬性包括撲克對象數組;主要方法有初始化、洗牌、輸出等。 3、編寫測試程序。

              #include#include#include#include#include#includeusing namespace std;class Card{public:string color;string point;Card(string color, string point);Card(string point);void display();void battle(Card card1);};class Cards{public:        vectorcard;        Cards();void display_all();        void shufflePoker();};Card::Card(string color, string point){this->color = color;    this->point = point;}Card::Card(string point){this->color = "";    this->point = point;}void Card::display(){string s = this->color + this->point;    cout<<Spoint])coutpointcolor])coutpoint<<ENDL;ELSE color])coutpoint<<ENDL;ELSECOUTpoint<<endl;}}cards::cards(){string colors[]={"黑心", "紅心", "草花", "方塊"};    string numbers[]={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};    for(int i=0;i<4;i++)    {for(int j=0;j<13;j++) this-="">card.push_back(Card(colors[i], numbers[j]));        }    }    this->card.push_back(Card("", "大王"));    this->card.push_back(Card("", "小王"));}void Cards::shufflePoker(){srand((unsigned int)time(0));random_shuffle(this->card.begin(), this->card.end());}void Cards::display_all(){for(int i=0;i<CARD.SIZE();I++) --="" {cout<card[i].color;cout<card[i].point + "\t";    }    cout<cout<<"初始化撲克牌:"<

              運行結果

              責任編輯:

              標簽:

              相關推薦:

              精彩放送:

              新聞聚焦
              Top 中文字幕在线观看亚洲日韩