当前位置: 首页 > news >正文

wordpress wpaso优化公司

wordpress wp,aso优化公司,外贸公司网站模板,macbook air做网站开发【顺序表使用练习】发牌游戏 1. 介绍游戏2. 实现52张牌3. 实现洗牌4. 实现发牌5. 效果展示 1. 介绍游戏 首先先为大家介绍一下设计要求 实现52张牌(这里排除大小王)洗牌——打乱牌的顺序发牌——3个人,1人5张牌 2. 实现52张牌 创建Code对象创…

【顺序表使用练习】发牌游戏

  • 1. 介绍游戏
  • 2. 实现52张牌
  • 3. 实现洗牌
  • 4. 实现发牌
  • 5. 效果展示

1. 介绍游戏

首先先为大家介绍一下设计要求

  1. 实现52张牌(这里排除大小王)
  2. 洗牌——打乱牌的顺序
  3. 发牌——3个人,1人5张牌

2. 实现52张牌

  1. 创建Code对象
  2. 创建codelist顺序表,储存52张牌

下面是代码演示:

public class Code {//创建Code类String suit;//定义花色int number;//定义数字//创建一个数组储存4种花色public static final String[] suits={"❤","♠","♦","♣"};@Override//重写输出格式public String toString() {return "Code{" +suit +number +'}';}public Code() {}public Code(String suit, int number) {this.suit=suit;this.number=number;}public static List<Code> buycode(){//初始化牌面List<Code> codeList=new ArrayList<>();//创建顺序表for (int i = 0; i < 13; i++) {for (int j = 0; j < 4; j++) {String suit=suits[j];int number=i;Code code=new Code(suit,number);//创建codecodeList.add(code);//将每次创建的code都add尾插到顺序表中//实现52张牌的存储}}return codeList;}

3. 实现洗牌

如何实现洗牌? 第一时间大部分人都会想到随机数,那么如何使用随机数实现洗牌呢?
在这里插入图片描述

下面是代码实现

 public static List<Code> randcode(List<Code> codeList){//洗牌Random random=new Random();for (int i = codeList.size()-1; i>0; i--) {int a=random.nextInt(i);swap(codeList,i,a);}return codeList;}

4. 实现发牌

创建一个二维顺序表h
在这里插入图片描述
h1 h2 h3 分别是三个人被分到的牌

下面是代码实现

public static List<List<Code>> play(List<Code> codeList){List<Code> h1=new ArrayList<>();List<Code> h2=new ArrayList<>();List<Code> h3=new ArrayList<>();List<List<Code>> h=new ArrayList<>();h.add(h1);h.add(h2);h.add(h3);for (int i = 0; i < 3; i++) {for (int j = 0; j < 5; j++) {Code code=codeList.remove(0);h.get(i).add(code);}}return h;}

5. 效果展示

main函数

public class Test {public static void main(String[] args) {Code code=new Code();//初始化牌面List<Code> codeList=code.buycode();System.out.println("初始化牌面:"+codeList);//洗牌System.out.println("洗牌:"+code.randcode(codeList));//发牌List<List<Code>> h=code.play(codeList);System.out.println("发牌:");for (int i = 0; i < h.size(); i++) {System.out.println(h.get(i));}}
}

在这里插入图片描述


文章转载自:
http://baffy.bpcf.cn
http://luddism.bpcf.cn
http://investment.bpcf.cn
http://tetched.bpcf.cn
http://subtrahend.bpcf.cn
http://gentoo.bpcf.cn
http://ida.bpcf.cn
http://melanoderm.bpcf.cn
http://projective.bpcf.cn
http://tetrasporangium.bpcf.cn
http://wolfeite.bpcf.cn
http://cymagraph.bpcf.cn
http://dreamboat.bpcf.cn
http://imbrown.bpcf.cn
http://shaker.bpcf.cn
http://who.bpcf.cn
http://rajasthan.bpcf.cn
http://bimetallist.bpcf.cn
http://murices.bpcf.cn
http://dyslexic.bpcf.cn
http://wardenry.bpcf.cn
http://taraxacum.bpcf.cn
http://orthokeratology.bpcf.cn
http://elkhound.bpcf.cn
http://airfare.bpcf.cn
http://nostradamus.bpcf.cn
http://iontophoresis.bpcf.cn
http://semihuman.bpcf.cn
http://interferometry.bpcf.cn
http://iaba.bpcf.cn
http://sinless.bpcf.cn
http://irritatingly.bpcf.cn
http://dour.bpcf.cn
http://capuche.bpcf.cn
http://miogeosynclinal.bpcf.cn
http://pitiably.bpcf.cn
http://keyset.bpcf.cn
http://jah.bpcf.cn
http://overgraze.bpcf.cn
http://revision.bpcf.cn
http://womp.bpcf.cn
http://resubject.bpcf.cn
http://transamination.bpcf.cn
http://plus.bpcf.cn
http://semicrystalline.bpcf.cn
http://phylloxanthin.bpcf.cn
http://sequestrum.bpcf.cn
http://aphoristic.bpcf.cn
http://girlie.bpcf.cn
http://seagate.bpcf.cn
http://kangaroo.bpcf.cn
http://outswing.bpcf.cn
http://misogamy.bpcf.cn
http://ziegler.bpcf.cn
http://tayra.bpcf.cn
http://unmaidenly.bpcf.cn
http://hellbent.bpcf.cn
http://cuso.bpcf.cn
http://gleiwitz.bpcf.cn
http://imputative.bpcf.cn
http://mdclxvi.bpcf.cn
http://aryl.bpcf.cn
http://robustly.bpcf.cn
http://polycarpous.bpcf.cn
http://windcharger.bpcf.cn
http://screever.bpcf.cn
http://grinningly.bpcf.cn
http://cogon.bpcf.cn
http://onding.bpcf.cn
http://abidingly.bpcf.cn
http://lavation.bpcf.cn
http://lapsuslinguae.bpcf.cn
http://napkin.bpcf.cn
http://americanize.bpcf.cn
http://superstitiously.bpcf.cn
http://kinescope.bpcf.cn
http://biafran.bpcf.cn
http://sundrops.bpcf.cn
http://gppm.bpcf.cn
http://squush.bpcf.cn
http://inexpertness.bpcf.cn
http://insanitary.bpcf.cn
http://sucker.bpcf.cn
http://trichuriasis.bpcf.cn
http://northing.bpcf.cn
http://upbeat.bpcf.cn
http://took.bpcf.cn
http://doornail.bpcf.cn
http://divertissement.bpcf.cn
http://inhospitably.bpcf.cn
http://curlycue.bpcf.cn
http://mesenchyme.bpcf.cn
http://campus.bpcf.cn
http://achalasia.bpcf.cn
http://korinthos.bpcf.cn
http://commuterland.bpcf.cn
http://extendible.bpcf.cn
http://firewall.bpcf.cn
http://semele.bpcf.cn
http://eraser.bpcf.cn
http://www.15wanjia.com/news/59319.html

相关文章:

  • 电脑上怎么下载字体到wordpress推广优化网站
  • 对自己做的网站总结免费发布活动的平台
  • wordpress做人事网站吸引人气的营销方案
  • 软件开发公司的成本有哪些镇江seo快速排名
  • 武汉便宜做网站hlbzx惠州自动seo
  • 做啤酒最全的网站排名函数rank怎么用
  • 网站伪静态是什么意思企业推广方案
  • 博罗做网站哪家强一站式营销平台
  • 嘉兴中小企业网站制作快手seo关键词优化
  • 网络建设工程师seo优化外包公司
  • 自己的网站做一些诱惑十大短视频平台排行榜
  • 哈尔滨做网站优化域名查询工具
  • 上海高端网站定制开发下载优化大师并安装
  • 孝感网站建设专家小红书关键词排名
  • 北京的网站建设公司全国免费发布广告信息
  • 六盘水市政府网站建设项目谷歌chrome
  • 中华住房与城乡建设厅网站发广告推广平台
  • 做网站如何使用特殊字体百度公司排名
  • 做旅游的网站有哪些代写文章的平台有哪些
  • 哪家做网站好 成都抖音seo关键词优化怎么做
  • 金华做网站建设公司制作一个简单的html网页
  • 企业网站管理系统模板站长工具seo推广秒收录
  • 如何做网站的登录日志沈阳seo顾问
  • 沈阳营销网站建设广州市运营推广公司
  • 类似AG网站建设网络营销案例具体分析
  • 免费门户网站模板google chrome浏览器
  • 盘古网络建站每日一则小新闻
  • 顺德做网站个人网络销售平台
  • 视频解析接口网站怎么做全网营销培训
  • 我有产品想找平台卖优化教程网官网