import [Link].
ArrayList;
import [Link];
class Main{
public static void main(String[] args) {
Main main = new Main();
[Link]();
}
private void run(){
PokerApp spil = new PokerApp();
[Link]();
}
}
class PokerApp {
Deck deck = new Deck();
ArrayList<PokerPlayer> pokerPlayers = new ArrayList<>();
PokerApp (){
public void startGame (){
registerPlayers("Günther","Olga");
welcomeToTheGame();
dealCards();
checkHands();
}
private void registerPlayers (String... players){
[Link]("Registering players...");
[Link]();
[Link]("Players registered: "+[Link]);
[Link]();
for (String player:players) {
[Link](new PokerPlayer(player, deck));
}
}
private void welcomeToTheGame() {
[Link]("Welcome to PokerApp!");
[Link]();
[Link]("Initiating game...");
[Link]();
}
private void dealCards (){
[Link]("Dealing cards...");
for (PokerPlayer player:pokerPlayers) {
[Link](player);
}
[Link]("Deck cards remaining: "+[Link]()+"\n");
}
// highestCard() – find and return the highest card of a players hand.
// int noOfSpades() – return the number of spades in a players hand.
// int noOfSuit(String suit) - return the number of cards of the same suit as
the parameter suit.
// boolean flush() – return true if all cards in a players hand are of the same
suit.
private void checkHands (){
[Link]("Checking hands...");
for (PokerPlayer player:pokerPlayers) {
[Link](player);
checkHand([Link]);
}
}
private void checkHand(ArrayList<Card> hand) {
// check for 1) royal flush, 2) straight flush, 3) 4 of a kind, 4) full
house, 5) flush, 6) straight
// check for 5) 4 of a kind, 6) full house, 7) 3 of a kind, 8) 2 pair, 9) 1
pair, 10) high card
private void compareHands (ArrayList<Card> hand) {
[Link]("Comparing hands...");
[Link]();
[Link]("The winner is: " + hand);
}
}
class PokerPlayer {
String name;
Hand handOfPlayer;
PokerPlayer(String playerName, Deck currentDeck) {
[Link] = new Hand(currentDeck);
[Link] = playerName;
}
@Override
public String toString (){
ArrayList<String> handString = new ArrayList<>();
for (Card card : [Link]) {
[Link]([Link]());
}
return "Player: "+[Link]+"'s hand: "+[Link]()+"\n";
}
}
class Hand {
private final static int handSize = 5;
ArrayList<Card> hand = new ArrayList<>(handSize);
Hand(Deck currentDeck) {
hand = initializeHand(currentDeck);
}
private ArrayList<Card> initializeHand (Deck currentDeck){
for (int i=0;i<handSize;i++) {
[Link]([Link]());
}
return hand;
}
}
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;
final ArrayList<Card> deck;
Deck() {
deck = new ArrayList<>(DECK_SIZE);
initializeDeck();
}
private void initializeDeck (){
for (int s=0;s<SUIT_SIZE;s++){
for (int r=0;r<RANK_SIZE;r++){
Card card = new Card();
[Link](s);
[Link](r);
[Link](card);
}
}
}
public Card drawCard (){
int nr = getRandomCardIndex();
return [Link](nr);
}
private int getRandomCardIndex (){
Random random = new Random();
return [Link]([Link]());
}
}
class Card {
private String suit;
private int rank;
private final String[] suits= {"Hearts", "Diamonds", "Clubs", "Spades"};
Card (){
[Link] = getRandomSuit();
[Link] = getRandomRank();
}
// getCardInfo
String getCardInfo (){
String cardInfo;
return cardInfo = [Link] + " of " + [Link];
}
// getRandom functions for ...
String getRandomSuit(){
return [Link][(int)([Link]()*4)];
}
int getRandomRank(){
return [Link] = (int)([Link]()*13+1);
}
// set functions for Deck(), and maybe cheating later.
void setSuit(int s){
if (s<=4) {
[Link] = suits[s];
}
}
void setRank(int r){
if (r<=13) {
[Link] = r;
}
}
@Override
public String toString(){
return suit+" of "+rank;
}
}