大一下的实践之一,保存一下代码。
package First;
import java.text.*;
import javax.swing.JOptionPane;
public class AY2016PokerProject
{
static String userMessage = "";
static final int handSize = 5;
static double totalWinnings = 0.0;
public static void main(String[] args)
{
int[] cards = new int[handSize];
int[] suits = new int[handSize];
int[] values = new int[handSize];
int winType;
String selection = "", playAgain = "";
do
{
while (!(selection.equals("1")) && !(selection.equals("0")))
{
selection = JOptionPane.showInputDialog(null,
"1. Play Poker\n" + "0. Quit\n" + "Please enter your selection");
if (selection == null)
selection = "0";
if (!(selection.equals("1")) && !(selection.equals("0")))
JOptionPane.showMessageDialog(null, "Invalid selection - please try again\n");
}
if (selection.equals("1"))
{
userMessage = "";
generateUniqueHand(cards);
determineSuitsAndValuesOfCards(cards, suits, values);
orderValuesAndSuits(suits, values);
displayCardsToEndUser(suits, values);
winType = evaluateHandOfCards(suits, values);
displayTypeOfWinIfAny(winType);
displayAmountWonIfAnything(winType);
JOptionPane.showMessageDialog(null, userMessage);
do
{
playAgain = JOptionPane.showInputDialog(null, "Would you like to play another game? (y/n)");
if (playAgain == null)
playAgain = "N"