Okay this is my first question on here. but essentially I have 2 codes (one written by someone else) and mine is supposed to implement their code. and in this code i am supposed to deal out 2 hands of 5 cards. compare each card of 1 hand to the other cards of the same hand.<-- thats where my problem is.
In my code i am only comparing the 1st element of the array to the rest. i need to compare each element to the remainder of the array
(MY CODE)
public class cardTester
{
public static void main(String[] args)
{
Card[] hand1 = new Card[5];
Card[] hand2 = new Card[5];
int pair1;
pair1 =0;
System.out.println("Player1 hand");
for(int x=0; x<1; x++)//<--if i use 5 or hand1.length here it will give me 5 different hands.
{
Card card1 = new Card();
card1.printCard();
System.out.println();
hand1[x] = card1;
for(int y=1; y<5; y++)
{
Card card2 = new Card();
card2.printCard();
System.out.println();
hand1[y] = card2;
if(hand1[x].face() == hand1[y].face())
pair1++;
}
System.out.println(pair1);
}
System.out.println("Player2 hand");
for(int i=0; i<hand2.length; i++)
{
Card card1 = new Card();
card1.printCard();
System.out.println();
hand2[i] = card1;
}
}
}
-----------------------------------------------------------------------------------------------
I am going to see my TA tomorrow reguardless, but i was wondering if anyone here could help me.