当前位置:网站首页>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();
}
}

边栏推荐
- Chapter 17 free space management
- C language learning log 10.5
- Opencv image storage and reading
- 语音信号分帧的理解
- How to lay copper in AD (aluminum designer)
- Red Treasure Book Reading Notes (continuously updated)
- 135. distribute candy
- Std:: map insert details
- QT interface rendering style
- Simple SR: best buddy Gans for highly detailed image super resolution
猜你喜欢

Draw a hammer

Brick story

Mysql8.0.13 installation tutorial (with pictures)

Robot pose description and coordinate transformation

Keil uses j-link to burn the code, and an error occurs: Flash download failed - one of the "Cortex-M3" solutions

Gradient descent, learning rate

Spice story

Logical point

About mission planning and improving execution

Time display of the 12th Blue Bridge Cup
随机推荐
Chapter 2 process management
Draw a hammer
Red Treasure Book Reading Notes (continuously updated)
【线程/多线程】线程的执行顺序
17.6 unique_ Lock details
About mission planning and improving execution
17.6 unique_lock详解
Sampo Lock
C language learning log 12.14
Recursion and recursion
PostgreSQL Guide: Insider exploration (Chapter 7 heap tuples and index only scanning) - Notes
RMQ、LCA
2021tami/ image processing: exploiting deep generative priority for versatile image restoration and manipulation
All blog navigation
Kaggle 时间序列教程
Dynamic and static libraries
Mysql8.0.13 installation tutorial (with pictures)
Differences between string() and tostring() methods
Leetcode game 297 (20220612)
QT signal is automatically associated with the slot