⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deal.java

📁 it contains the practical programs in our college
💻 JAVA
字号:
import java.util.*;public class Deal {    public static void main(String[] args) {	if (args.length < 2) {	    System.out.println("Usage: Deal hands cards");	    return;	}	int numHands = Integer.parseInt(args[0]);	int cardsPerHand = Integer.parseInt(args[1]);	List<Card> deck = Deck.newDeck();	Collections.shuffle(deck);	if (numHands * cardsPerHand > deck.size()) {	    System.out.println("Not enough cards.");	    return;	}	for (int i = 0; i < numHands; i++)	    System.out.println(dealHand(deck, cardsPerHand));    }    public static ArrayList<Card> dealHand(List<Card> deck, int n) {	int deckSize = deck.size();	List<Card> handView = deck.subList(deckSize-n, deckSize);	ArrayList<Card> hand = new ArrayList<Card>(handView);	handView.clear();	return hand;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -