{"id":11029,"date":"2026-02-12T15:14:09","date_gmt":"2026-02-12T07:14:09","guid":{"rendered":"https:\/\/yiqihuijia.com.cn\/index.php\/2026\/02\/12\/%e7%94%a8java%e5%88%9b%e5%bb%ba%e7%ae%80%e5%8d%95%e6%89%91%e5%85%8b%e7%89%8c%e6%b8%b8%e6%88%8f%ef%bc%8c%e6%95%99%e4%bd%a0%e6%80%8e%e4%b9%88%e5%88%b6%e4%bd%9c%e5%be%b7%e5%b7%9e%e6%89%91%e5%85%8b\/"},"modified":"2026-02-12T15:14:09","modified_gmt":"2026-02-12T07:14:09","slug":"%e7%94%a8java%e5%88%9b%e5%bb%ba%e7%ae%80%e5%8d%95%e6%89%91%e5%85%8b%e7%89%8c%e6%b8%b8%e6%88%8f%ef%bc%8c%e6%95%99%e4%bd%a0%e6%80%8e%e4%b9%88%e5%88%b6%e4%bd%9c%e5%be%b7%e5%b7%9e%e6%89%91%e5%85%8b","status":"publish","type":"post","link":"https:\/\/qqovblr.com\/index.php\/2026\/02\/12\/%e7%94%a8java%e5%88%9b%e5%bb%ba%e7%ae%80%e5%8d%95%e6%89%91%e5%85%8b%e7%89%8c%e6%b8%b8%e6%88%8f%ef%bc%8c%e6%95%99%e4%bd%a0%e6%80%8e%e4%b9%88%e5%88%b6%e4%bd%9c%e5%be%b7%e5%b7%9e%e6%89%91%e5%85%8b\/","title":{"rendered":"\u7528Java\u521b\u5efa\u7b80\u5355\u6251\u514b\u724c\u6e38\u620f\uff0c\u6559\u4f60\u600e\u4e48\u5236\u4f5c\u5fb7\u5dde\u6251\u514b\u6e38\u620f"},"content":{"rendered":"<p>Player.java<\/p>\n<p>import java.util.ArrayList;<\/p>\n<p>import java.util.List;<\/p>\n<p>public class Player {<\/p>\n<p>public   int  id;\/\/ID<\/p>\n<p>public String name;\/\/\u540d\u5b57<\/p>\n<p>public  Listcards;\/\/\u624b\u724c<\/p>\n<p>\u516c\u5171\u573a\u5408\u4e0b\uff0c\u73a9\u5bb6\uff0c\u6709\u6574\u578b\u7684\u8eab\u4efd\u6807\u8bc6\uff0c\u8fd8\u6709\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u540d\u5b57 \uff0c\u8fd9\u79cd\u521d\u59cb\u64cd\u4f5c\u3002<\/p>\n<p>this.id = id;<\/p>\n<p>this.name = name;<\/p>\n<p>this.cards = new ArrayList();<\/p>\n<p>public String size() {<\/p>\n<p>\/\/ TODO \u81ea\u52a8\u751f\u6210\u7684\u65b9\u6cd5\u5b58\u6839<\/p>\n<p>return null;<\/p>\n<p>Puke.java<\/p>\n<p>public\uff0c\u7c7b\uff0cPuke\uff0c\u5b9e\u73b0\uff0cComparable \uff0c\u8fd9\u51e0\u4e2a\u8bcd\uff0c\u88ab\u7ec4\u5408\u5728\u4e86\u4e00\u8d77\u3002<\/p>\n<p>public String color;\/\/\u724c\u7684\u82b1\u8272<\/p>\n<p>public String num;\/\/\u724c\u7684\u70b9\u6570<\/p>\n<p>this.color = color;\/\/\u724c\u7684\u82b1\u8272<\/p>\n<p>this.num = num ;\/\/\u724c\u7684\u70b9\u6570<\/p>\n<p>\/*<\/p>\n<p>* \u5b9a\u4e49<a href='\/index.php\/2026\/02\/10\/%e6%b5%99%e6%b1%9f%e8%bf%99%e5%ba%a7%e5%b0%8f%e5%9f%8e-%e4%bc%9a%e6%98%af%e6%89%93%e6%89%91%e5%85%8b%e7%89%8c%e6%8e%bc%e8%9b%8b%e7%9a%84%e6%9c%80%e5%a4%a7%e8%b5%a2%e5%ae%b6%ef%bc%9f\/' title='\u6251\u514b\u724c' target='_blank'>\u6251\u514b\u724c<\/a>\u7684\u89c4\u5219<\/p>\n<p>\u7559\u610f\uff0c\u53c2\u7167\uff0cJava\u8bed\u8a00\u4e2d\u7684\u53ef\u6bd4\u8f83\u63a5\u53e3\uff0c\u5176\u5305\u542b\u7684\u65b9\u6cd5\uff0c\u7528\u4e8e\u6bd4\u8f83\uff0c\u4e0e\u6307\u5b9a\u5bf9\u8c61\uff0c\u5bf9\u6bd4\u7684\u65f6\u5019\uff0c\u4f7f\u7528\u7684\u65b9\u6cd5\uff0c\u540d\u4e3a\u6bd4\u8f83\u5230\uff0c\u63a5\u53d7\u7684\u53c2\u6570\u7c7b\u578b\u4e3a\u5bf9\u8c61\uff0c\u5177\u4f53\u6240\u5728\u7684\u7c7b\u4e3aJava\u8bed\u8a00\u4e2d\u7684\u5bf9\u8c61\u7c7b\u3002<\/p>\n<p>*\/<\/p>\n<p>\u516c\u5f00\u7684\u6574\u578b\uff0c\u6bd4\u8f83\u65b9\u6cd5\uff0c\u53c2\u6570\u4e3a\u6251\u514b\u5bf9\u8c61\uff0c\u8fdb\u884c\u6bd4\u8f83\u3002<\/p>\n<p>if (this.num == o.num)<\/p>\n<p>if (this.color.equals(&#8220;\u9ed1\u6843&#8221;))<\/p>\n<p>return 1;<\/p>\n<p>else\u82e5\u8be5\u60c5\u51b5\u5b58\u5728\uff08this.color\u7b49\u540c\u4e8e\u201c\u7ea2\u6843\u201d\u8fd9\u79cd\u72b6\u51b5\uff09\uff0c\u5219\u4f1a\u51fa\u73b0\u76f8\u5e94\u60c5\u5f62\uff0c\u5177\u4f53\u4e3a\uff08this.color\u7b49\u4e8e\u201c\u7ea2\u6843\u201d\uff09<\/p>\n<p>if (o.color.equals(&#8220;\u9ed1\u6843&#8221;))<\/p>\n<p>{ return -1;<\/p>\n<p>else {<\/p>\n<p>return 1;<\/p>\n<p>\u5982\u679c\u4e0d\u662f\u8fd9\u79cd\u60c5\u51b5\uff0c\u800c\u662f\u5f53\u8fd9\u4e2a\u989c\u8272\u7b49\u4e8e\u201c\u6885\u82b1\u201d\u7684\u65f6\u5019\u3002<\/p>\n<p>\u8981\u662f\uff08\u5bf9\u8c61o\u7684\u989c\u8272\u7b49\u540c\u4e8e\u201c\u9ed1\u6843\u201d\u6216\u8005\u5bf9\u8c61o\u7684\u989c\u8272\u7b49\u540c\u4e8e\u201c\u7ea2\u6843\u201d\uff09\uff01<\/p>\n<p>return -1; }<\/p>\n<p>else<\/p>\n<p>return 1;<\/p>\n<p>else<\/p>\n<p>return -1;<\/p>\n<p>else<\/p>\n<p>if (this.num.equals(&#8220;A&#8221;))<\/p>\n<p>return 1;<\/p>\n<p>\u8f6c\u800c\u5018\u82e5\uff0c\u6b64\u6570\u5b57\u7b49\u540c\u4e8e\uff0c\u201cK\u201d \u8fd9\u4e2a\u5b57\u7b26\u3002<\/p>\n<p>if (o.num.equals(&#8220;A&#8221;))<\/p>\n<p>return -1;<\/p>\n<p>else<\/p>\n<p>return 1;<\/p>\n<p>\u5426\u5219\uff0c\u5982\u679c\uff0c\u8fd9\u4e2a\uff0c\u6570\u5b57\uff0c\u7b49\u4e8e\uff0c\u53cc\u5f15\u53f7\u91cc\u7684\uff0c\u5927\u5199\u5b57\u6bcdQ\u3002<\/p>\n<p>\u8981\u662f\uff08o\u7684num\u7b49\u4e8e&#8221;A&#8221;  \u6216\u8005  o\u7684num\u7b49\u4e8e&#8221;K&#8221;\uff09\u3002<\/p>\n<p>return -1;<\/p>\n<p>else<\/p>\n<p>return 1;<\/p>\n<p>\u5426\u5219\uff0c\u5982\u679c\uff0c\u8fd9\u4e2a\uff0c\u6570\u5b57\uff0c\u7b49\u4e8e\uff0c\u53cc\u5f15\u53f7\u62ec\u8d77\u6765\u7684\uff0c\u5b57\u6bcd J\u3002<\/p>\n<p>\u5982\u679c\uff0co\u7684num\u7b49\u4e8e&#8221;A&#8221;\uff0c\u6216\u8005\uff0co\u7684num\u7b49\u4e8e&#8221;K&#8221;\uff0c\u6216\u8005\uff0co\u7684num\u7b49\u4e8e&#8221;Q&#8221;\u3002<\/p>\n<p>return -1;<\/p>\n<p>else { return 1;<\/p>\n<p>\u53e6\u5916\u8981\u662f\uff0c\u8fd9\u4e2a\u6570\u5b57\u7b49\u4e8e\uff0c\u201c10\u201d  \uff0c\u8fd9\u79cd\u60c5\u51b5 \uff0c\u90a3\u53c8\u5982\u4f55\u3002<\/p>\n<p>\u8981\u662f\uff08\u5bf9\u8c61o\u7684num\u8fd9\u4e2a\u5c5e\u6027\u7b49\u4e8e&#8221;A&#8221;\u6216\u8005\u5bf9\u8c61o\u7684num\u8fd9\u4e2a\u5c5e\u6027\u7b49\u4e8e&#8221;K&#8221;\u6216\u8005\uff09<\/p>\n<p>o\u7684num\u7b49\u4e8e&#8221;Q&#8221;\uff0c\u6216\u8005\uff0co\u7684num\u7b49\u4e8e&#8221;J&#8221;)\u3002<\/p>\n<p>return -1;<\/p>\n<p>else<\/p>\n<p>return 1;<\/p>\n<p>else<\/p>\n<p>\u8fd4\u56de\uff0c\u8fd9\u4e2a\uff0c\u6570\u5b57\uff0c\u4e0e\uff0c\u5bf9\u8c61\u7684\uff0c\u6570\u5b57\uff0c\u8fdb\u884c\uff0c\u6bd4\u8f83\u7684\uff0c\u7ed3\u679c\uff0c\u6807\u70b9\u7b26\u53f7\u4e3a\u5206\u53f7\u3002<\/p>\n<p>PlayGames.java<\/p>\n<p>import java.util.ArrayList;<\/p>\n<p>import java.util.Collections;<\/p>\n<p>import java.util.List;<\/p>\n<p>import java.util.Scanner;<\/p>\n<p>\/*<\/p>\n<p>* \u6251\u514b\u724c<a href='\/index.php\/2026\/02\/11\/%e5%8f%97%e6%ac%a2%e8%bf%8e%e7%a8%8b%e5%ba%a6%ef%bc%9a%e5%85%a8%e5%9b%bd-2\/' title='\u6e38\u620f' target='_blank'>\u6e38\u620f<\/a>\uff1a<\/p>\n<p>* 1\u3001\u521b\u5efa\u4e00\u526f\u6251\u514b\u724c\uff0c\u9664\u53bb\u5927\u5c0f\u738b<\/p>\n<p>* 2\u3001\u767b\u5f55\u4e24\u4f4d\u73a9\u5bb6<\/p>\n<p>* 3\u3001\u968f\u673a\u6d17\u724c<\/p>\n<p>* 4\u3001\u987a\u5e8f\u53d1\u724c<\/p>\n<p>\u5148\u53bb\u6bd4\u8f83\u70b9\u6570\uff0c\u4e4b\u540e\u518d\u6bd4\u8f83\u82b1\u8272\uff0c\u9ed1\u6843\u5927\u4e8e\u7ea2\u6843\uff0c\u7ea2\u6843\u5927\u4e8e\u6885\u82b1\uff0c\u6885\u82b1\u5927\u4e8e\u65b9\u7247\u3002<\/p>\n<p>*\/<\/p>\n<p>public class PlayGames {<\/p>\n<p>public Listallpuke;<\/p>\n<p>public void  playgames(){<\/p>\n<p>\u8fd9\uff0c\u6240\u6709\u5455\u5410\u7269\uff0c\u88ab\u521b\u5efa\u4e3a\uff0c\u4e00\u4e2a\u65b0\u7684\uff0c\u6570\u7ec4\u5217\u8868\u3002<\/p>\n<p>\u5217\u4e3e\u6240\u6709\uff0c\u5455\u5410\u7269\u7b49\u4e8e\u65b0\u7684\uff0c\u4e00\u4e2a\u6570\u7ec4\u5217\u8868\u3002<\/p>\n<p>\/*<\/p>\n<p>* \u521b\u5efa\u4e00\u526f\u6251\u514b\u724c<\/p>\n<p>*\/<\/p>\n<p>public void porke(){<\/p>\n<p>System.out.println(&#8220;\u521b\u5efa\u6251\u514b\u724c&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u65b9\u7247A&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u6885\u82b1A&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u7ea2\u6843A&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u9ed1\u6843A&#8221;);<\/p>\n<p>for(int i=2;i<\/p>\n<p>allpukes.add(&#8220;\u65b9\u7247&#8221;+i);<\/p>\n<p>allpukes.add(&#8220;\u6885\u82b1&#8221;+i);<\/p>\n<p>allpukes.add(&#8220;\u7ea2\u6843&#8221;+i);<\/p>\n<p>allpukes.add(&#8220;\u9ed1\u6843&#8221;+i);<\/p>\n<p>allpukes.add(&#8220;\u65b9\u7247J&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u6885\u82b1J&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u7ea2\u6843J&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u9ed1\u6843J&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u65b9\u7247Q&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u6885\u82b1Q&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u7ea2\u6843Q&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u9ed1\u6843Q&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u65b9\u7247K&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u6885\u82b1K&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u7ea2\u6843K&#8221;);<\/p>\n<p>allpukes.add(&#8220;\u9ed1\u6843K&#8221;);<\/p>\n<p>\u5c06\u201callpukes\u201d\u5e94\u7528\u201ctoString\u201d\u65b9\u6cd5\u8f6c\u800c\u5f62\u6210\u7684\u7ed3\u679c\uff0c\u8d4b\u503c\u7ed9\u540d\u4e3a\u201cstr\u201d\u7684\u201cString\u201d\u7c7b\u578b\u53d8\u91cf\u3002<\/p>\n<p>System.out.println(&#8220;&#8212;&#8212;&#8212;\u6251\u514b\u724c\u521b\u5efa\u6210\u529f\uff1a&#8212;&#8212;&#8211;&#8220;);System.out.println(str)\u3002<\/p>\n<p>\/*<\/p>\n<p>* \u6253\u4e71\u987a\u5e8f<\/p>\n<p>*\/<\/p>\n<p>public void shuffle(){<\/p>\n<p>\u5bf9\u4e8e\u201cSystem.out.println\u201d\uff0c\u5bf9\u5176\u8fdb\u884c\u64cd\u4f5c\uff0c\u64cd\u4f5c\u5185\u5bb9\u4e3a\u8f93\u51fa\u8bed\u53e5\uff0c\u8f93\u51fa\u7684\u5177\u4f53\u4fe1\u606f\u662f\u201c&#8212;&#8212;&#8212;\u5f00\u59cb\u6d17\u724c&#8212;&#8212;&#8211;\u201d\uff0c\u6b64\u4e3a\u4e00\u4e2a\u53e5\u5b50\uff0c\u53e5\u672b\u6709\u6807\u70b9\u7b26\u53f7\u3002<\/p>\n<p>\/\/\u968f\u673a\u6253\u4e71\u987a\u5e8f\u7528List\u65b9\u6cd5<\/p>\n<p>Collections\u8fdb\u884c\u6d17\u724c\u64cd\u4f5c\uff0c\u9488\u5bf9\u7684\u662f\u6240\u6709\u7684\u6251\u514b\u724c\u3002<\/p>\n<p>\u7a0b\u5e8f\u90a3\u7528\u4e8e\u6807\u51c6\u8f93\u51fa\u7684\u8bed\u53e5\uff0c\u6253\u5370\u8f93\u51fa\u4e86\u8fd9\u6837\u4e00\u4e32\u5b57\u7b26\uff0c\u5373\u201c&#8212;&#8212;&#8212;\u6d17\u724c\u7ed3\u675f&#8212;&#8212;&#8212;-\u201d\u3002<\/p>\n<p>\/*<\/p>\n<p>* \u521b\u5efa\u73a9\u5bb6ID  \u548c\u73a9\u5bb6\u59d3\u540d<\/p>\n<p>*\/<\/p>\n<p>public void PutPlayers(){<\/p>\n<p>\u7cfb\u7edf\u8f93\u51fa\u6253\u5370\uff0c\u8f93\u51fa\u5185\u5bb9\u4e3a\uff0c\u53cc\u5f15\u53f7\u5185\u7684\uff0c\u6a2a\u7ebf\u8fde\u63a5\u7740\u7684\u4e09\u4e2a\u5b57\uff0c\u521b\u5efa\uff0c\u73a9\u5bb6\uff0c\u521b\u5efa\u73a9\u5bb6\u5fb7\u4fe1\u7ade\u6280\uff0c\u53cc\u5f15\u53f7\u5185\u7684\u5185\u5bb9\uff0c\u5206\u53f7\u7ed3\u5c3e\u3002\u7ed3\u675f\u3002\u7ed3\u675f\uff0c\u5192\u53f7\u7ed3\u675f\uff0c\u5192\u53f7\u7ed3\u675f\u3002<\/p>\n<p>for (int i = 1; i &lt; 3; i++)<\/p>\n<p>System.out.println(&#8220;\u8bf7\u8f93\u5165\uff0c\u7b2c&#8221; + (i) +&#8221;\u4f4d\u73a9\u5bb6\u7684\uff0cID\u548c\u59d3\u540d\uff1a&#8221;)\u3002<\/p>\n<p>System.out.println(&#8220;\u8f93\u5165ID:&#8221;);<\/p>\n<p>int id = 0; ;<\/p>\n<p>\u7531\u7cfb\u7edf\u7684\u8f93\u5165\u6765\u5f04\u51fa\u4e00\u4e2a\u65b0\u7684\u626b\u63cf\u5668\uff0c\u8fd9\u626b\u63cf\u5668\u88ab\u547d\u540d\u4e3a\u626b\u63cf\u5668\uff0c\u5b83\u5b58\u5728\u4e8e\u4e00\u4e2a\u88ab\u53eb\u505a\u626b\u63cf\u5668\u7684\u53d8\u91cf\u4f53\u5185\u3002<\/p>\n<p>while(true)<\/p>\n<p>try{<\/p>\n<p>\u628a\u901a\u8fc7\u626b\u63cf\u5668\u8bfb\u53d6\u7684\u4e0b\u4e00\u884c\u5185\u5bb9\u53bb\u9664\u9996\u5c3e\u7a7a\u767d\u540e\uff0c\u8f6c\u6362\u4e3a\u6574\u6570\u7c7b\u578b\uff0c\u5176\u7ed3\u679c\u8d4b\u503c\u7ed9id\u3002<\/p>\n<p>break;<\/p>\n<p>\u5f53\u6355\u6349\u5230\u6570\u5b57\u683c\u5f0f\u5f02\u5e38\u7684\u60c5\u51b5\u65f6\uff0c\u4e5f\u5c31\u662f\u6355\u83b7\u5230\u7f16\u53f7\u683c\u5f0f\u65b9\u9762\u8fdd\u89c4\u7684\u5f02\u5e38\uff0c\u4ee5e\u6765\u8868\u793a\u8fd9\u4e2a\u5f02\u5e38\u3002<\/p>\n<p>\u5c06\u201c\u8bf7\u8f93\u5165\u6574\u6570\u7c7b\u578b\u7684ID\uff01\u201d\u8f93\u51fa\u81f3\u63a7\u5236\u53f0\uff0c\u8fd9\u662f\u901a\u8fc7System.out.println\u8bed\u53e5\u6765\u8fbe\u6210\u7684\u3002<\/p>\n<p>System.out.println(&#8220;\u518d\u6b21\u53bb\u8f93\u5165ID:&#8221;); \u63a5\u7740\u7ee7\u7eed\u3002<\/p>\n<p>System.out.println(&#8220;\u8f93\u5165\u59d3\u540d:&#8221;);<\/p>\n<p>\u58f0\u660e\u4e00\u4e2a\u540d\u4e3aname\u7684\u5b57\u7b26\u4e32\u53d8\u91cf\uff0c\u8ba9\u5b83\u7b49\u4e8e\u901a\u8fc7\u626b\u63cf\u5668\u83b7\u53d6\u7684\u4e0b\u4e00\u884c\u8f93\u5165\u5185\u5bb9\u3002<\/p>\n<p>\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3aplayer\u7684\u5bf9\u8c61\uff0c\u8be5\u5bf9\u8c61\u5c5e\u4e8ePlayer\u7c7b\u578b\uff0c\u5e76\u4e14\u901a\u8fc7\u4f20\u5165id\u548cname\u6765\u8fdb\u884c\u521d\u59cb\u5316\u3002<\/p>\n<p>players.add(player);<\/p>\n<p>\u8fd9\u884c\u4ee3\u7801\u7684\u76ee\u6807\u529f\u80fd\u662f\uff0c\u5c06\u7279\u5b9a\u7684\u6587\u672c\u5185\u5bb9\uff0c\u4e5f\u5c31\u662f\u201c&#8212;-\u6b22\u8fce\u73a9\u5bb6\uff1a\u201d \uff0c\u4e0e\u73a9\u5bb6\u5217\u8868\u4e2d\u7d22\u5f15\u4e3a0\u7684\u73a9\u5bb6\u7684\u540d\u5b57\uff0c\u8fdb\u884c\u62fc\u63a5\u7ec4\u5408\uff0c\u7136\u540e\u4f7f\u7528\u7cfb\u7edf\u8f93\u51fa\u7c7b\u7684\u6253\u5370\u65b9\u6cd5\uff0c\u8f93\u51fa\u663e\u793a\u5728\u63a7\u5236\u53f0\u3002<\/p>\n<p>System.out.println(&#8220;&#8212;-&#8220;&#8221;\u6b22\u8fce\u73a9\u5bb6\uff1a&#8221;, players.get(1).name)\u3002<\/p>\n<p>\/*<\/p>\n<p>* \u5f00\u59cb\u53d1\u724c<\/p>\n<p>*\/<\/p>\n<p>public void dealCard(){<\/p>\n<p>System.out.println(&#8220;&#8212;&#8212;&#8212;\u7740\u624b\u53d1\u724c&#8212;&#8212;&#8211;&#8220;)\u3002<\/p>\n<p>\u7cfb\u7edf\u8f93\u51fa\u6253\u5370\uff0c\u8f93\u51fa\u5185\u5bb9\u4e3a\uff0c\u201c&#8212;&#8212;&#8212;\u73a9\u5bb6\uff0c\u8be5\u73a9\u5bb6\u662fplayers\u83b7\u53d6\u7684\u7b2c0\u4e2a\u5143\u7d20\u7684name\u5c5e\u6027\u503c\uff0c\u8fdb\u884c\u62ff\u724c&#8212;&#8211;\u201d\u3002<\/p>\n<p>\u73a9\u5bb6\u83b7\u53d6\u5230\u7684\u7f16\u53f7\u4e3a 0 \u7684\u5bf9\u8c61\u5361\u7247\uff0c\u6dfb\u52a0\u8fdb\u4e86\u6240\u6709\u6251\u514b\u724c\u83b7\u53d6\u5230\u7684\u7f16\u53f7\u4e3a 0 \u7684\u90a3\u5f20\u724c\u3002<\/p>\n<p>System.out.println(&#8220;&#8212;&#8212;&#8212;&#8220;&#8221;\u73a9\u5bb6&#8221;, players.get(1).name&#8221;\u62ff\u724c&#8212;&#8211;&#8220;)\u3002<\/p>\n<p>\u73a9\u5bb6\u83b7\u53d6\u7f16\u53f7\u4e3a1\u7684\u5bf9\u8c61\uff0c\u8be5\u5bf9\u8c61\u7684\u5361\u7247\u6570\u7ec4\u6dfb\u52a0\u5168\u90e8\u6251\u514b\u724c\u4e2d\u7f16\u53f7\u4e3a1\u7684\u90a3\u5f20\u724c\u3002<\/p>\n<p>System.out.println(&#8220;&#8212;&#8212;&#8212;\u73a9\u5bb6&#8221;+players.get(0).name+&#8221;\u62ff\u724c&#8212;&#8211;&#8220;);<\/p>\n<p>\u73a9\u5bb6\u83b7\u53d6\u5230\u7684\u7b2c\u4e00\u4e2a\u7269\u54c1\uff0c\u5176\u5361\u7247\u90e8\u5206\u6dfb\u52a0\u4e86\u6240\u6709\u6251\u514b\u4e2d\u83b7\u53d6\u5230\u7684\u7b2c\u4e09\u4e2a\u7269\u54c1\u3002<\/p>\n<p>System.out.println(&#8220;&#8212;&#8212;&#8212;\u73a9\u5bb6&#8221;+players.get(1).name+&#8221;\u62ff\u724c&#8212;&#8211;&#8220;);<\/p>\n<p>\u6570\u7ec4players\u4e2d\u7d22\u5f15\u4e3a1\u7684\u5143\u7d20\u6240\u5177\u6709\u7684cards\u5c5e\u6027\uff0c\u6dfb\u52a0allpukes\u6570\u7ec4\u4e2d\u7d22\u5f15\u4e3a3\u7684\u5143\u7d20\u3002<\/p>\n<p>System\uff08\uff09\uff0cout\uff08\uff09\uff0cprintln\uff08\uff09\uff0c\uff08\u201c&#8212;&#8212;&#8211;\u53d1\u724c\u7ed3\u675f&#8212;&#8212;&#8211;\u201d\uff09\u3002<\/p>\n<p>\/*<\/p>\n<p>* \u5f00\u59cb\u6e38\u620f<\/p>\n<p>*\/<\/p>\n<p>\u91c7\u7528\u6291\u5236\u8b66\u544a\u7684\u65b9\u5f0f\uff0c\u5c06\u8b66\u544a\u7c7b\u578b\u8bbe\u5b9a\u4e3a\u672a\u7ecf\u6821\u9a8c\u7684\u7c7b\u578b \uff0c\u5e76\u8fdb\u884c\u6291\u5236\u3002<\/p>\n<p>public void starGame(){<\/p>\n<p>System.out.println(&#8220;&#8212;&#8212;\u6e38\u620f\u5f00\u59cb&#8212;&#8212;&#8211;&#8220;)\u3002<\/p>\n<p>\u628a\u73a9\u5bb6\u83b7\u53d6\u7684\u9996\u5f20\u5361\u7247\u8fdb\u884c\u6392\u5e8f\uff0c\u901a\u8fc7\u67d0\u79cd\u96c6\u5408\u6392\u5e8f\u65b9\u5f0f\uff0c\uff0c\u8fd9\u79cd\u65b9\u5f0f\u662f\u7279\u5b9a\u96c6\u5408\u7c7b\u6240\u5177\u5907\u7684\u6392\u5e8f\u3002<\/p>\n<p>\u63d0\u53d6\u73a9\u5bb6\u5217\u8868\u4e2d\u9996\u4e2a\u73a9\u5bb6\u7684\u624b\u724c collection\uff0c\u7136\u540e\u83b7\u53d6\u8be5\u96c6\u5408\u4e2d\u7684\u7b2c\u4e8c\u9879\u5143\u7d20\uff0c\u518d\u5c06\u5176\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff0c\u8d4b\u503c\u7ed9\u540d\u4e3a maxCard \u7684\u5b57\u7b26\u4e32\u53d8\u91cf\u3002 \u7136\u540e \uff0c \u8d4b\u503c\u7ed9\u540d\u4e3amaxCard\u7684\u5b57\u7b26\u4e32\u53d8\u91cf\u3002<\/p>\n<p>\u5c06\u201cSystem.out.println\u201d\u5199\u6210\u201c\u7cfb\u7edf\u8f93\u51fa\u6253\u5370\u201d\uff0c\u628a\u201c\u73a9\u5bb6\uff1a\u201d\u5199\u6210\u201c\u73a9\u5bb6\u540d\u4e3a\u201d\uff0c\u628a\u201c\u6700\u5927\u7684\u624b\u724c\u662f\uff1a\u201d\u5199\u6210\u201c\u6700\u5927\u624b\u724c\u4e3a\u201d\uff0c\u6539\u5199\u540e\u7684\u5185\u5bb9\u4e3a\uff1a\u7cfb\u7edf\u8f93\u51fa\u6253\u5370\uff08\u73a9\u5bb6\u540d\u4e3a + players.get(0).name + \u6700\u5927\u624b\u724c\u4e3a + maxCard\uff09\u3002<\/p>\n<p>\u9488\u5bf9\u73a9\u5bb6\u961f\u5217\u4e2d\u4f4d\u4e8e\u7d22\u5f151\u4f4d\u7f6e\u5143\u7d20\u6240\u6301\u6709\u7684\u5361\u7247\u96c6\u5408\uff0c\u8fdb\u884c\u6392\u5e8f\u64cd\u4f5c \uff0c\u901a\u8fc7\u4f7f\u7528\u96c6\u5408\u7c7b\u6240\u63d0\u4f9b\u7684\u6392\u5e8f\u65b9\u6cd5\u3002<\/p>\n<p>\u5148\u83b7\u53d6players\u5217\u8868\u4e2d\u7d22\u5f15\u4e3a1\u7684\u5143\u7d20\uff0c\u518d\u83b7\u53d6\u8be5\u5143\u7d20\u7684cards\u5217\u8868\u4e2d\u7d22\u5f15\u4e3a1\u7684\u5143\u7d20\uff0c\u63a5\u7740\u8c03\u7528\u8be5\u5143\u7d20\u7684toString\u65b9\u6cd5\uff0c\u6700\u540e\u5c06\u7ed3\u679c\u8d4b\u503c\u7ed9maxCard1\u3002<\/p>\n<p>System.out.println(&#8220;\u73a9\u5bb6\uff1a&#8221;, players.get(0).name&#8221;\u6700\u5927\u7684\u624b\u724c\u662f\uff1a&#8221;, maxCard1)\u3002<\/p>\n<p>\u5b9a\u4e49\u4e00\u4e2a\u540d\u53ebListgameCard\u7684\u5bf9\u8c61\uff0c\u4f7f\u5176\u7b49\u4e8e\u4e00\u4e2a\u65b0\u5efa\u7684ArrayList\u5bf9\u8c61\u3002<\/p>\n<p>gameCard\uff0c\u5168\u90e8\u6dfb\u52a0\uff0c\u73a9\u5bb6\u83b7\u53d6\u7684\uff0c\u4f4d\u4e8e\u7d22\u5f15\u4e3a0\u5904\u7684\uff0c\u5361\u7247\u96c6\u5408\u4e2d\u7684\u5361\u7247\u3002<\/p>\n<p>\u5c06\u73a9\u5bb6\u5217\u8868\u4e2d\u7d22\u5f15\u4e3a1\u7684\u73a9\u5bb6\u6240\u62e5\u6709\u7684\u5361\u7247\uff0c\u4e00\u4e00\u6dfb\u52a0\u5230\u6e38\u620f\u5361\u7247\u96c6\u5408\u4e4b\u4e2d\u3002<\/p>\n<p>Collections.sort(gameCard);<\/p>\n<p>\u8981\u662f\uff08\u73a9\u5bb6\u4eec\u83b7\u53d6\u5230\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u6240\u5305\u542b\u7684\u5361\u7247\u5f53\u4e2d\uff0c\u6709\u6e38\u620f\u533a\u57df\u5361\u7247\u96c6\u5408\u91cc\u6700\u540e\u4e00\u4e2a\u4f4d\u7f6e\u7684\u90a3\u5f20\u5361\u7247\u5728\u5176\u4e2d\uff09\uff0c\u90a3\u4e48\u3002<\/p>\n<p>\u8f93\u51fa\u8bed\u53e5\uff0c\u6253\u5370\u51fa\uff0c\u201c&#8212;&#8212;-\u73a9\u5bb6\u201d\u52a0\u4e0a\u201cplayers\u201d\u83b7\u53d6\u7684\u7b2c0\u4e2a\u5143\u7d20\u7684\u201cname\u201d\u5c5e\u6027\u503c\uff0c\u518d\u52a0\u4e0a\u201c\u8d62\u4e86&#8212;&#8212;&#8211;\u201d\u3002<\/p>\n<p>}else<\/p>\n<p>System\uff0cout\uff0cprintln\uff0c\uff08&#8221;&#8212;&#8212;-\u73a9\u5bb6&#8221;\uff0cplayers\uff0c.\uff0cget\uff0c\uff081\uff09\uff0c.\uff0cname&#8221;\u8d62\u4e86&#8221;&#8221;&#8212;&#8212;&#8211;&#8220;\uff09\u3002<\/p>\n<p>\/*<\/p>\n<p>* \u67e5\u770b\u73a9\u5bb6\u7684\u724c<\/p>\n<p>*\/<\/p>\n<p>\u5b9a\u4e49\u4e00\u4e2a\u516c\u5171\u7684\u65b9\u6cd5\uff0c\u8be5\u65b9\u6cd5\u7528\u4e8e\u68c0\u67e5\u73a9\u5bb6\u5361\u7247\u3002<\/p>\n<p>\u5bf9\u4e8e\u7cfb\u7edf\u8f93\u51fa\u6253\u5370\u8bed\u53e5\uff0c\u5176\u5185\u5bb9\u4e3a\u201c&#8212;&#8212;&#8212;&#8212;-\u5404\u4f4d\u73a9\u5bb6\u7684\u724c\u662f&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;\u201d \uff0c\u8fd9\u662f\u4e00\u4e2a\u7528\u4e8e\u5728\u63a7\u5236\u53f0\u663e\u793a\u7279\u5b9a\u6587\u672c\u4fe1\u606f\u7684\u64cd\u4f5c \uff0c\u901a\u8fc7\u8be5\u8bed\u53e5\u53ef\u4ee5\u5c06\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u5448\u73b0\u51fa\u6765\u3002<\/p>\n<p>Collections.sort(players.get(0).cards);<\/p>\n<p>\u5c06\u53d8\u91cf\u201cplayerCard1\u201d\u8d4b\u503c\u4e3a\uff0c\u4ece\u96c6\u5408\u201cplayers\u201d\u6309\u7167\u7d22\u5f15\u201c0\u201d\u83b7\u53d6\u7684\u5361\u724c\u5bf9\u8c61\uff0c\u8c03\u7528\u5176\u201ctoString\u201d\u65b9\u6cd5\u6240\u8fd4\u56de\u7684\u5b57\u7b26\u4e32\u7ed3\u679c\u3002<\/p>\n<p>\u8ba9\u7cfb\u7edf\u8f93\u51fa\uff0c\u6253\u51fa\u8fd9\u6837\u4e00\u884c\u5b57\uff0c\u73a9\u5bb6\uff0c\u90a3\u4e2a\u4ece\u73a9\u5bb6\u5217\u8868\u91cc\u83b7\u53d6\u5230\u7684\u6392\u5728\u6700\u524d\u9762\u7684\u73a9\u5bb6\uff0c\u5176\u540d\u5b57\u6240\u5bf9\u5e94\u7684\u5185\u5bb9\uff0c\u7684\u724c\u662f\uff0c\u90a3\u4e2a\u540c\u6837\u4ece\u73a9\u5bb6\u5217\u8868\u91cc\u83b7\u53d6\u5230\u7684\u6392\u5728\u6700\u524d\u9762\u7684\u73a9\u5bb6\uff0c\u5176\u6301\u6709\u7684\u724c\u6240\u5bf9\u5e94\u7684\u5185\u5bb9\u3002<\/p>\n<p>Collections.sort(players.get(1).cards);<\/p>\n<p>\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u73a9\u5bb6\u5361\u72472 \uff0c\u7b49\u4e8e \u73a9\u5bb6\u5217\u8868\u4e2d\u83b7\u53d6\u5230\u7684\u7d22\u5f15\u4e3a1\u7684\u73a9\u5bb6\u7684\u5361\u7247 \uff0c\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u5f62\u5f0f\u3002<\/p>\n<p>System.out.println(&#8220;\u73a9\u5bb6&#8221;, players.get(1).name&#8221;\u7684\u724c\u662f&#8221;, players.get(1).cards)\u3002<\/p>\n<p>\u516c\u5f00\u9759\u6001\u65e0\u6548\u53bb\u6267\u884c\u4e3b\u8981\u7684\u65b9\u6cd5\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u7528\u5230\u53c2\u6570\u53eb\u505aargs \uff0c\u8fd9\u79cd\u60c5\u51b5\u662f\u5b58\u5728\u7684\u3002\u6807\u70b9\u7b26\u53f7\u4f7f\u7528\u53e5\u53f7\uff0c\u6807\u70b9\u7b26\u53f7\u4f7f\u7528\u53e5\u53f7\u3002<\/p>\n<p>\/\/ TODO \u81ea\u52a8\u751f\u6210\u7684\u65b9\u6cd5\u5b58\u6839<\/p>\n<p>\u628a\u90a3\u4e2a\u8fdb\u884c\u6807\u51c6\u8f93\u51fa\u7684\u65b9\u6cd5\u8c03\u7528\u8d77\u6765\u5370\u51fa\uff0c\u201c&#8212;&#8212;-\u6b22\u8fce\u6765\u5230\u6251\u514b\u724c\u738b\u56fd&#8212;&#8212;&#8212;-\u201d(\u53e5\u53f7\u5728\u5f15\u53f7\u5916)\u3002<\/p>\n<p>\u7cfb\u7edf\u8f93\u51fa\u6253\u5370\uff0c\u8f93\u51fa\u7684\u5185\u5bb9\u662f\uff0c\u53cc\u5f15\u53f7\u62ec\u4f4f\u7684\uff0c\u6a2a\u7ebf\u6a2a\u7ebf\u6a2a\u7ebf\uff0c\u662f\u5426\u8981\u5f00\u59cb\u6e38\u620f\uff0c\u53cc\u5f15\u53f7\u62ec\u4f4f\uff0c\u5206\u53f7\u3002<\/p>\n<p>System.out.println(&#8220;&#8212;&#8212;&#8212;&#8212;-\u8981\u662f\u9009\u62e9\u80af\u5b9a\u7684\u8bdd\u5c31\u6309\u952e\uff1a1  &#8212; \u8981\u662f\u9009\u62e9\u5426\u5b9a\u7684\u8bdd\u5c31\u6309\u952e\uff1a0&#8212;&#8212;-&#8220;)\u3002<\/p>\n<p>\u65b0\u5efa\u4e86\u4e00\u4e2aScanner\u5bf9\u8c61\uff0c\u5c06\u5176\u547d\u540d\u4e3ascanner\uff0c\u8be5\u5bf9\u8c61\u7528\u4e8e\u4ece\u7cfb\u7edf\u8f93\u5165\u4e2d\u83b7\u53d6\u6570\u636e\u3002<\/p>\n<p>int a = scanner.nextInt();<\/p>\n<p>if(a == 1){<\/p>\n<p>while(true){<\/p>\n<p>\u65b0\u5efa\u4e00\u4e2a\u540d\u4e3aPlayGames\u7684\u5bf9\u8c61\uff0c\u5c06\u5176\u8d4b\u503c\u7ed9\u4e00\u4e2a\u540d\u4e3apl\u7684PlayGames\u7c7b\u578b\u53d8\u91cf\u3002<\/p>\n<p>pl.porke();<\/p>\n<p>\/\/pl.foreachPuke();<\/p>\n<p>pl.shuffle();<\/p>\n<p>pl.PutPlayers();<\/p>\n<p>pl.dealCard();<\/p>\n<p>\u8fdb\u884c\u8f93\u51fa\u64cd\u4f5c\u4e86\uff0c\u8f93\u51fa\u7684\u5185\u5bb9\u662f\u201c&#8212;&#8212;-\u662f\u5426\u5f00\u59cb\u51fa\u724c&#8211;\u662f\u8bf7\u6309\uff1a1&#8212;&#8212;\u201d\u3002<\/p>\n<p>int b = scanner.nextInt();<\/p>\n<p>if(b == 1)<\/p>\n<p>pl.starGame();<\/p>\n<p>pl.checkplayerCard();<\/p>\n<p>\u7cfb\u7edf.out.\u6253\u5370\u8f93\u51fa(&#8220;&#8212;&#8212;&#8211;\u662f\u5426\u8981\u7ee7\u7eed\u6e38\u620f&#8212;&#8212;&#8212;&#8220;)\u3002<\/p>\n<p>System.out.println(&#8220;&#8212;&#8212;\u82e5\u8981\u7ee7\u7eed\u8bf7\u6309\uff1a1&#8212;&#8211;\u8981\u662f\u9000\u51fa\u8bf7\u6309\uff1a0&#8212;&#8212;&#8220;)\u3002<\/p>\n<p>int c = scanner.nextInt();<\/p>\n<p>if(c == 1){<\/p>\n<p>continue;<\/p>\n<p>else{<\/p>\n<p>break;<\/p>\n<p>\u7cfb\u7edf\u8f93\u51fa\u6253\u5370\u51fa\uff0c\u201c&#8212;&#8212;&#8212;\u611f\u8c22\u60a8\u7684\u53c2\u4e0e&#8212;&#8212;&#8212;\u201d\u3002<\/p>\n<p>else{<\/p>\n<p>\u7cfb\u7edf\u8f93\u51fa\u6253\u5370\uff0c\u8f93\u51fa\u5185\u5bb9\u4e3a\uff0c\u4e00\u6761\u7531\u53cc\u5f15\u53f7\u5305\u88f9\u7684\uff0c\u5305\u542b\u591a\u4e2a\u6a2a\u7ebf\u7684\uff0c\u8868\u8ff0\u7740\u6b22\u8fce\u4e0b\u6b21\u518d\u6765\u610f\u601d\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u7b2c\u4e09\u5b63\u770b\u5b8c\u540e\uff0c\u597d\u591a\u65b9\u6cd5\u7684\u5b9e\u8df5\u7528\u6cd5\u4e0d\u592a\u660e\u767d\uff0c\u8d77\u521d\u7740\u5b9e\u4e0d\u77e5\u4ece\u54ea\u7740\u624b\uff0c\u63a5\u7740\u56de\u770b\u89c6\u9891\u91cc\u7684\u8bb2\u89e3\uff0c\u8fd8\u53c2\u7167\u81ea\u5df1\u6572\u7684\u4ee3\u7801\uff0c\u53c8\u53c2\u7167\u4e86\u5176\u4ed6\u4eba\u7684\u4ee3\u7801\uff0c\u6700\u7ec8\u5b8c\u6210\u4e86\u8fd9\u4e2a\u6251\u514b\u724c\u6e38\u620f\uff0c\u671b\u80fd\u4f9b\u5927\u5bb6\u53c2\u8003\uff01\u5927\u4f19\u4e00\u540c\u52aa\u529b\uff0c\u5171\u540c\u8fdb\u6b65\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb595\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u4e00\u4e2a\u4f7f\u7528Java\u5b9e\u73b0\u7684\u6251\u514b\u724c\u6e38\u620f\uff0c\u5305\u62ec\u521b\u5efa\u724c\u7ec4\u3001\u73a9\u5bb6\u767b\u5f55\u3001\u968f\u673a\u6d17\u724c\u3001\u53d1\u724c\u53ca\u6bd4\u8f83\u5927\u5c0f\u7b49\u529f\u80fd\u3002\u901a\u8fc7\u5177\u4f53\u4ee3\u7801\u5b9e\u73b0\u4e86\u6e38\u620f\u903b\u8f91<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[7313,7314,7315,258,94],"class_list":["post-11029","post","type-post","status-publish","format-standard","hentry","category-pkxw","tag-java","tag-player","tag-puke","tag-258","tag-94"],"_links":{"self":[{"href":"https:\/\/qqovblr.com\/index.php\/wp-json\/wp\/v2\/posts\/11029","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qqovblr.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qqovblr.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qqovblr.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qqovblr.com\/index.php\/wp-json\/wp\/v2\/comments?post=11029"}],"version-history":[{"count":0,"href":"https:\/\/qqovblr.com\/index.php\/wp-json\/wp\/v2\/posts\/11029\/revisions"}],"wp:attachment":[{"href":"https:\/\/qqovblr.com\/index.php\/wp-json\/wp\/v2\/media?parent=11029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qqovblr.com\/index.php\/wp-json\/wp\/v2\/categories?post=11029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qqovblr.com\/index.php\/wp-json\/wp\/v2\/tags?post=11029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}