我正在创建一个Java扑克游戏到目前为止我已经让我的程序为玩家,经销商和董事会(河流)选择随机卡。我现在希望我的玩家能够输入一个值作为赌注,我虽然使用“Scanner bet = new Scanner(System.in);
”但是如果经销商获胜,我还需要一个底池和底池值。我认为我需要有2或3个名单玩家的现金,Pot,Houses现金。
到目前为止,这是我的代码: -
public PockerMain() {
// TODO Auto-generated constructor stub
}
public static void main(String[] args)
{
List<PokerCard> deck = cardDeck();
System.out.println(deck.size() + " Cards In Deck");
System.out.println();
playersHand(deck);
housesHand(deck);
theBoard(deck);
System.out.println(deck.size() + " Cards In Deck");
}
public static void playersHand(List<PokerCard> deck)
{
PokerCard selectedCard = nextCardToPick(deck);
PokerCard secondSelectedCard = secondCardToPick(deck);
System.out.println(selectedCard + " this your random card");
System.out.println(secondSelectedCard + " this is your other card");
System.out.println();
Scanner bet = new Scanner(System.in);
}
public static void housesHand(List<PokerCard> deck)
{
PokerCard dealersFirstCard = dealerHandFirstCard(deck);
PokerCard dealersSecondCard = dealerHandSecondCard(deck);
System.out.println(dealersFirstCard + " this is the dealers random card");
System.out.println(dealersSecondCard + " this is the dealers other card");
System.out.println();
}
public static void theBoard(List<PokerCard> deck)
{
PokerCard firstBoardCard = boardCardOne(deck);
PokerCard secondBoardCard = boardCardTwo(deck);
PokerCard thirdBoardCard = boardCardThree(deck);
PokerCard forthBoardCard = boardCardFour(deck);
PokerCard fithBoardCard = boardCardFive(deck);
System.out.println(firstBoardCard + " this is the first card on the board");
System.out.println(secondBoardCard + " this is the second card on the board");
System.out.println(thirdBoardCard + " this is the third card on the board");
System.out.println(forthBoardCard + " this is the forth card on the board");
System.out.println(fithBoardCard + " this is the fith card on the board");
System.out.println();
}
private static PokerCard createCard (short suit, short rank)
{
PokerCard card = new PokerCard (suit, rank);
return card;
}
private static List<PokerCard> cardDeck ()
{
List<PokerCard> deck = new ArrayList<PokerCard> ();
for (int i = 0; i < 4; i ++)
{
for (int j = 0; j < 13; j ++)
{
PokerCard card = createCard ((short)i, (short)j);
deck.add(card);
}
}
return deck;
}
/**
* this selects a card and the removes it from the list of cards
* @param cardDeck is the list of cards
* @return a random card selected from the cardDeck
*/
private static PokerCard nextCardToPick(List<PokerCard> cardDeck)
{
Random random = new Random();
int nextCardToPick = random.nextInt(cardDeck.size());//get random number in range 0 - deck.size (assuming 52 cards then it will give value between 0 -51)
PokerCard selectedCard = cardDeck.get(nextCardToPick);
cardDeck.remove(selectedCard);//this will remove the card from the cardDeck
return selectedCard;
}
private static PokerCard secondCardToPick(List<PokerCard> cardDeck)
{
Random random = new Random();
int secondCardToPick = random.nextInt(cardDeck.size());//get random number in range 0 - deck.size (assuming 52 cards then it will give value between 0 -51)
PokerCard secondSelectedCard = cardDeck.get(secondCardToPick);
cardDeck.remove(secondSelectedCard);//this will remove the card from the cardDeck
return secondSelectedCard;
}
private static PokerCard dealerHandFirstCard(List<PokerCard> cardDeck)
{
Random random = new Random();
int dealerHandFirstCard = random.nextInt(cardDeck.size());//get random number in range 0 - deck.size (assuming 52 cards then it will give value between 0 -51)
PokerCard dealersFirstCard = cardDeck.get(dealerHandFirstCard);
cardDeck.remove(dealersFirstCard);//this will remove the card from the cardDeck
return dealersFirstCard;
}
private static PokerCard dealerHandSecondCard(List<PokerCard> cardDeck)
{
Random random = new Random();
int dealerHandSecondCard = random.nextInt(cardDeck.size());//get random number in range 0 - deck.size (assuming 52 cards then it will give value between 0 -51)
PokerCard dealersSecondCard = cardDeck.get(dealerHandSecondCard);
cardDeck.remove(dealersSecondCard);//this will remove the card from the cardDeck
return dealersSecondCard;
}
private static PokerCard boardCardOne(List<PokerCard> cardDeck)
{
Random random = new Random();
int boardCardOne = random.nextInt(cardDeck.size());//get random number in range 0 - deck.size (assuming 52 cards then it will give value between 0 -51)
PokerCard firstBoardCard = cardDeck.get(boardCardOne);
cardDeck.remove(firstBoardCard);//this will remove the card from the cardDeck
return firstBoardCard;
}
private static PokerCard boardCardTwo(List<PokerCard> cardDeck)
{
Random random = new Random();
int boardCardTwo = random.nextInt(cardDeck.size());//get random number in range 0 - deck.size (assuming 52 cards then it will give value between 0 -51)
PokerCard secondBoardCard = cardDeck.get(boardCardTwo);
cardDeck.remove(secondBoardCard);//this will remove the card from the cardDeck
return secondBoardCard;
}
private static PokerCard boardCardThree(List<PokerCard> cardDeck)
{
Random random = new Random();
int boardCardThree = random.nextInt(cardDeck.size());//get random number in range 0 - deck.size (assuming 52 cards then it will give value between 0 -51)
PokerCard thirdBoardCard = cardDeck.get(boardCardThree);
cardDeck.remove(thirdBoardCard);//this will remove the card from the cardDeck
return thirdBoardCard;
}
private static PokerCard boardCardFour(List<PokerCard> cardDeck)
{
Random random = new Random();
int boardCardFour = random.nextInt(cardDeck.size());//get random number in range 0 - deck.size (assuming 52 cards then it will give value between 0 -51)
PokerCard forthBoardCard = cardDeck.get(boardCardFour);
cardDeck.remove(forthBoardCard);//this will remove the card from the cardDeck
return forthBoardCard;
}
private static PokerCard boardCardFive(List<PokerCard> cardDeck)
{
Random random = new Random();
int boardCardFive = random.nextInt(cardDeck.size());//get random number in range 0 - deck.size (assuming 52 cards then it will give value between 0 -51)
PokerCard fithBoardCard = cardDeck.get(boardCardFive);
cardDeck.remove(fithBoardCard);//this will remove the card from the cardDeck
return fithBoardCard;
}
}
如果你可以帮助或指出我需要去的方向,这将是伟大的。
答案 0 :(得分:1)
首先想到的是你应该做Player对象。它包括: - 2张扑克牌 - 玩家/经销商拥有的金额
现在方法:
希望这有帮助