当前位置:网站首页>Case - simulated landlords (primary version)
Case - simulated landlords (primary version)
2022-06-13 05:05:00 【Jason_ LH1024】
package it.com;
import java.util.ArrayList;
import java.util.Collections;
public class Poker {
public static void main(String[] args) {
// Create a card box , That is to define a collection object , use ArrayList Set implementation
ArrayList<String> array = new ArrayList<>();
// Put cards in the card box
/*
2,3,4,5,6,,,,k,A,
2,...
2,...
2,...
King , Xiao Wang
*/
// Define an array of decors
String[] colors = {"", "", "", ""};
String[] numbers = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
for (String color : colors) {
for (String number : numbers) {
array.add(color + number);
}
}
array.add(" King ");
array.add(" Xiao Wang ");
// Shuffle , That is to break up the cards , use Collections Of shuffle() Method realization
Collections.shuffle(array);
// System.out.println(array);
// Deal is to traverse the set , Deal cards to three players
ArrayList<String> fulong = new ArrayList<>();
ArrayList<String> zhonglong = new ArrayList<>();
ArrayList<String> pinlong = new ArrayList<>();
ArrayList<String> dipai = new ArrayList<>();
for (int i = 0; i < array.size(); i++) {
String poker = array.get(i);
if (i >= array.size() - 3) {
dipai.add(poker);
} else if (i % 3 == 0) {
fulong.add(poker);
} else if (i % 3 == 1) {
zhonglong.add(poker);
} else if (i % 3 == 2) {
pinlong.add(poker);
}
}
// Look at cards , That is, three players traverse their cards respectively
lookPoker(" Rich peasants ",fulong);
lookPoker(" Middle peasants ",zhonglong);
lookPoker(" The poor peasants ",pinlong);
lookPoker(" a hand ",dipai);
}
// How to look at the cards
public static void lookPoker(String name,ArrayList<String> array){
System.out.print(name+" The card is :");
for (String poker:array) {
System.out.print(poker+" ");
}
System.out.println();
}
}
边栏推荐
- Advanced C language - Section 1 - data storage
- C language learning log 1.19
- File descriptorfile description
- Kaggle 时间序列教程
- Search DFS and BFS
- Clause 27: alternatives to overloading with familiar universal reference types
- Logical point
- C language learning log 1.16
- [reprint] complete collection of C language memory and character operation functions
- Leetcode game 297 (20220612)
猜你喜欢
Metartc4.0 integrated ffmpeg compilation
Infinite cycle scrolling code Alibaba international station store decoration code base map scrolling black translucent display effect custom content decoration code full screen display
Simple greedy strategy
Simple-SR:Best-Buddy GANs for Highly Detailed Image Super-Resolution論文淺析
Dup2 use
Explain the opencv function cv:: add() in detail, and attach sample code and running results of various cases
C language learning log 12.5
List collection concurrent modification exception
Section 2 - branch and loop statements
Binary search and binary answer
随机推荐
Sub paragraph of Chapter 16
Clause 31: avoid default capture mode
Simple sr: Best Buddy Gans for highly detailed image super resolution Paper Analysis
C language learning log 1.16
Embedded hardware: electronic components (1) resistance capacitance inductance
Spread your wings and soar
[leetcode]- sliding window
C language learning log 1.2
【线程/多线程】线程的执行顺序
On switch() case statement in C language
System file interface open
Luogu p1036 number selection
【多线程编程】Future接口获取线程执行结果数据
Optocoupler working principle function electric parameter application circuit
Chapter 15 mechanism: Address Translation
Section 4 - arrays
Simple-SR:Best-Buddy GANs for Highly Detailed Image Super-Resolution论文浅析
Nonstandard compiler attribute extension
RMQ、LCA
RuoYi-Cloud启动教程(手把手图文)