Message
Message
ArrayList;
import java.util.Random;
class Main{
public static void main(String[] args) {
Main main = new Main();
main.run();
}
private void run(){
PokerApp spil = new PokerApp();
spil.startGame();
}
}
class PokerApp {
Deck deck = new Deck();
ArrayList<PokerPlayer> pokerPlayers = new ArrayList<>();
PokerApp (){
class PokerPlayer {
String name;
Hand handOfPlayer;
@Override
public String toString (){
ArrayList<String> handString = new ArrayList<>();
for (Card card : this.handOfPlayer.hand) {
handString.add(card.getCardInfo());
}
return "Player: "+this.name+"'s hand: "+handString.toString()+"\n";
}
}
class Hand {
private final static int handSize = 5;
ArrayList<Card> hand = new ArrayList<>(handSize);
Hand(Deck currentDeck) {
hand = initializeHand(currentDeck);
}
class Deck {
private static final int DECK_SIZE = 52; // constants: static final
private static final int SUIT_SIZE = 4;
private static final int RANK_SIZE = 13;
Deck() {
deck = new ArrayList<>(DECK_SIZE);
initializeDeck();
}
class Card {
private String suit;
private int rank;
private final String[] suits= {"Hearts", "Diamonds", "Clubs", "Spades"};
Card (){
this.suit = getRandomSuit();
this.rank = getRandomRank();
}
// getCardInfo
String getCardInfo (){
String cardInfo;
return cardInfo = this.rank + " of " + this.suit;
}
@Override
public String toString(){
return suit+" of "+rank;
}
}