I think I kind of fixed my problem. Here's my code:
Code:
public class Card {
int suit, rank;
int index = 0;
Card[] deck = new Card [52];
public Card () {
this.suit = 0; this.rank = 0;
}
public Card (int suit, int rank) {
this.suit = suit; this.rank = rank;
}
public void main(String[] args) {
for (suit = 0; suit <= 3; suit++) {
for (rank = 1; rank <= 13; rank++) {
deck[index] = new Card (suit, rank);
index++;
}
}
isFlush(deck,6);
}
public boolean isFlush(Card[] x, int y) {
int count = 0;
for(index = 0; index < y; index++){
boolean comp = compareCard(x[index], x[index + 1]);
if (comp = true){
count++;
}
}
if (count >= 5){
System.out.println("Congratulations! You have a flush!");
return true;
}
else{
System.out.println("Sorry, you do not have a flush.");
return false;
}
}
public boolean compareCard(Card c1, Card c2){
if (c1.suit != c2.suit){
return false;
}
return true;
}
}
But now I'm getting this error:
java.lang.NoSuchMethodError: main
Exception in thread "main"
Exception in thread "main" Java Result: 1
I know I have to make my main method static but how can I reference my non static variables from main? Or what other workaround can I use to get this to work? Any help is appreciated.