Yes you have told me to use enums but my teacher JUST told me I'd fail if i did enums. she wnats me to do it in a 2d array
/*
Ryan Reese
This is like a poker simulation. Won't make it a GUI yet =/
Started December 8th, 2008
*/
//Importing a crap load of stuff to make this work
import java.util.Scanner;
import java.util.Random;
//Start the public class
public class Poker
{
//deck[suit][rank]
public static String[][] deck={{"CLUBS","DIAMONDS","SPADES","HEARTS"},{"TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE","TEN","JACK","QUEEN","KING","ACE"}};
//start the main method
public static void main(String args[])
{
//Initialize a variable representing poker. I can call methods and such now.
Poker poker=new Poker();
//Make it so i can read user input
Scanner input=new Scanner(System.in);
//Random generator
Random generator=new Random();
//Welcome the user and such.
System.out.println("Welcome to Poker!");
//Make the 5 cards
String card1=deal(generator.nextInt(4),generator.nextInt(12));
String card2=deal(generator.nextInt(4),generator.nextInt(12));
String card3=deal(generator.nextInt(4),generator.nextInt(12));
String card4=deal(generator.nextInt(4),generator.nextInt(12));
String card5=deal(generator.nextInt(4),generator.nextInt(12));
//Redeal 5 cards. May not be needed
String card6=deal(generator.nextInt(4),generator.nextInt(12));
String card7=deal(generator.nextInt(4),generator.nextInt(12));
String card8=deal(generator.nextInt(4),generator.nextInt(12));
String card9=deal(generator.nextInt(4),generator.nextInt(12));
String card10=deal(generator.nextInt(4),generator.nextInt(12));
System.out.println("Here are your 5 starting hands\n");
//Print out original 5 cards
System.out.println("1)"+card1);
System.out.println("2)"+card2);
System.out.println("3)"+card3);
System.out.println("4)"+card4);
System.out.println("5)"+card5);
//See which cards the user hates.
System.out.println("Would you like to keep card one/two/three/four/five?");
//Keep track of which they want to keep
boolean keepCard1=input.nextBoolean();
boolean keepCard2=input.nextBoolean();
boolean keepCard3=input.nextBoolean();
boolean keepCard4=input.nextBoolean();
boolean keepCard5=input.nextBoolean();
//If they dont want to keep card 1..then redeal
//So on and so forth
if(!keepCard1)
card1=card6;
if(!keepCard2)
card2=card7;
if(!keepCard3)
card3=card8;
if(!keepCard4)
card4=card9;
if(!keepCard5)
card5=card10;
//Print out the original 5 cards.
System.out.println("1)"+card1);
System.out.println("2)"+card2);
System.out.println("3)"+card3);
System.out.println("4)"+card4);
System.out.println("5)"+card5);
//Give user the new cards
System.out.println("Here are your (new) 5 cards");
System.out.println("1)"+card1);
System.out.println("2)"+card2);
System.out.println("3)"+card3);
System.out.println("4)"+card4);
System.out.println("5)"+card5);
//Determine what kind of hand the user has.
String hand=poker.determineHand(card1,card2,card3,card4,card5);
System.out.println(hand);
//Exit the program
System.exit(0);
}
public static String deal(int suit,int rank)
{
String card="";
//Making the deck out of the 2D array
for(int i=0;i<suit;i++)
{
for(int n=0;n<rank;n++)
{
}
}
return card;
}
public static String determineHand(String card1,String card2,String card3,String card4,String card5)
{
//Some awesome crap here to determine what kind of hand the user has
String hand="You have a ";
//If it is a flush
return hand;
}
}
Inside those two for loops, what exactly should i do? I'm thinking have an array cards[][] and in each position like cards[0][0]//that is 2 of clubs
that sound right or something? Then impliment something to shuffle?