




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
此程序为21点扑克牌游戏 玩家一共可以要五张牌 但如果牌的点数超过21 则自动出局 在不超过21点的情况下 玩家与庄家比牌的点数大小 大者为赢 相同则为平局 程序说明 1 将所有的函数与相应的数据封装到类中 并改写主程序 使程序简化 2 程序中一共有13张扑克牌可以随时抽取 大于10的点数为0 5 3 超级玩家永远不会输掉 即超级玩家可以查看下一张牌 若大于21点 则可以拒绝 当然游戏规则上不能泄露这点秘密 4 超级玩家可以查看下一张牌 即输入指定的字符串或字符 然后按要求输入正确密码后才能看自己的和计算机的牌 并指定下一级牌的点数 5 每次要牌后可以设定赔率 即如果开始下的是10元钱的注 如果牌好 你可以要求继续下注 当然不能超过你所有的总钱数 6 将界面的提示说明改成中文界面 界面的解释详细友好 可以吸引更多的玩家 类的封装 设计一个类 将出牌 下注等的操作包含进去 玩家和计算机 均为这个类的对象 这样 在玩牌及判断输赢时 函数只需要用这两个对象的引用做参数即可 大大简化了函数 具体的参考的数据结构如下 class CCard private int naPip 5 一共五张牌 int nNumber 实际发了多少牌 int nDollar 有多少钱 int nGamble 赌注 int nWin 赢局数 int nLost 输局数 int nDraw 平局数 public CCard 构造函数 初始化 void FirstPlayTwo 最初两张牌 int GetNumber 返回牌的张数 double GetPip 返回点数 void DidplayPip 依次显示牌面的点数 void DidplayPip int 除了第一张牌 依次全部显示牌面点数 针对计算机牌的显示 void TurnPlay 出一张牌 void Win 赢了计算赌注 void Lose 输了 void Draw 平局 int SetGamblec int 设置赌注 赌本不够返回 1 int GetMoney 返回钱数 void DisplayInfo 显示必要的信息 char GetCurrentCard 返回当前牌点 void DeleteCard void 删除当前牌点 作弊用 void ModifyCard double 修改当前牌 作弊用 int Addgamble int 加赌注 主程序 include include fuctions void replay char 询问玩家是否再玩一局 void hit int 要一张牌 void deal int 为计算机和玩家各发两张牌 void BET int 下注 void print int wins int lose int draw int money 输出最后结果 void rules 输出游戏规则 void results int player int cpu int bet int 判断一局的结果 diyige wait h begin include include void wait int milli 暂停 milli 毫秒 clock t start start clock while clock start milli wait h end include include include include void pause 暂停 任按一键继续 cout 任按一键继续 endl getch int GetInt int L 0 int H 100 int ent cout Please Enter A Number Between L and H ent while entH cout Error endl cout Value must be between L and H ent return ent void sign Displays ISAAC SHAFFER cout This Program Was Written By Isaac Shaffer endl int random long hi long lo This Program Finds A Random Number Between Hi and Low int ran srand unsigned time NULL ran rand hi lo 1 lo return ran utility h end int main int player 0 cpu 0 win 0 lose 0 draw 0 playerturns 0 cputurns 0 money 0 bet char ans system cls 执行系统命令 清屏 rules cout ans if ans y ans Y 检查输入是否为Yes cout t t t您的赌本为100美元 endl 起始的赌本 money 100 cout t t t pause 暂停 任按一键继续 else return 0 do system cls if money 0 看看有无赌本 cout 对不起 您没赌本了 endl 若赌本输光 结束程序 return 0 BET bet money 下注的程序 deal player cpu playerturns cputurns 给玩家和计算机各发两张牌 do cout ans if ans h ans H 如果玩家要牌 playerturns 玩家手中的牌数增加一张 if playerturns 5 判断玩家手中的牌数是否超过5张 cout t t t你手中的牌不能超过5张牌 若超过5张不能继续要牌 if playerturns 6 hit player 调用发牌程序 while ans h ans H 继续询问玩家是否要牌 for cpu 16 cputurns 计算机开始要牌的条件 cout endl cout t t t计算机要了一张牌 endl hit cpu 调用发牌程序 cout endl cout endl cout t t t计算机的牌面为 cpu endl 输出计算机的牌面的总点数 cout t t t您的牌面为 player endl 输出玩家的牌面的总点数 cout endl results player cpu bet money draw win lose 判断输赢 replay ans 询问是否继续玩牌 while ans y ans Y print win lose draw money 游戏结束 输出结果 cout endl cout t t t t return 0 void rules 游戏规则 cout t t WELCOME TO ISAAC SHAFFER S BLACK JACK GAME endl cout t t t HERE ARE SOME SIMPLE RULES endl cout t t t1 You Can only have a max of 5 cards endl cout t t t2 If you bust you automatically lose endl cout t t t3 If you win you win double what you bet endl cout t t t4 The Dealer stops at or after 16 endl cout t t t t pause void BET int cout t t t您现有的 money endl cout bet if bet 0 bet bet 1 money money bet void deal int playerturns 2 cputurns 2 playercard1 random 13 1 取得13与1之间的随机数 cout n t t tDEALING HAND 10 若牌面的点数大于10 按10来计点数 playercard1 10 if playercard2 10 playercard2 10 if cpucard1 10 cpucard1 10 if cpucard2 10 cpucard2 10 player playercard1 playercard2 玩家两张牌的总点数 cpu cpucard1 cpucard2 计算机两张牌的总点数 cout t t t现有您的牌面总数是 player endl cout playercard1 cout playercard2 cout endl cout t t t计算机有一张 cpucard1 显示 endl cout endl cout cpucard1 10 card 10 total total card 牌点总数 cout t t t牌面是 card endl 输出牌面 cout t t t总的牌面是 total endl 输出总点数 void results int player int cpu int bet int lose else if cpu player 玩家赢了 cout 21 计算机超过了21点 cout t t t计算机输了 endl if player 21 cout player cout t t t很遗憾 你输了 endl lose void replay char void print int wins int lose int draw int money cout t t t t赢的次数 wins endl cout t t t t输的次数 lose endl
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 福建电商营销方案设计
- 珍珠奶茶的营销方案策划
- 减肥水果营销策划方案
- 钢筋工程质量管理
- 酒店网站建设方案咨询
- 咨询方案的总结
- 钢箱梁施工方案整改
- 建筑方案设计资源包括哪些
- 跑步健身活动方案策划
- 人工智能技术与AIGC应用 课件全套 第1-8章 认识人工智能 - AIGC 的发展与展望
- 俄罗斯礼俗课件
- 2024统编版八年级历史上册全册知识点复习提纲
- 虚拟服装培训教程课件
- 2025年国防教育知识竞赛试题(附答案)
- 非车主押车借款合同范本
- T-CES 153-2022 电力巡检无人机边缘智能终端技术规范
- GJB2220A-2018 航空发动机用钛合金饼、环坯规范
- 《中国金融学》课件 第4章 信用形式与信用体系-课件
- 康复医生进修汇报课件
- 招标及采购基础知识培训课件
- 中国邮政储蓄银行2025年反洗钱知识考试题库(带答案)
评论
0/150
提交评论