enum Cards {
ENERGY(6),
CORVETE(2),
BATTLE_HAMMER(2),
BATTLE_CRUISER(2),
BATTLE_AXE(2),
COLONY_SHIP(2),
CONSTRUCTOR(2),
DEFENDER(2),
FRIGATE(2),
SCOUT(2),
STAR_FIGHTER(2),
STAR_HAWK(2),
SURVEY_SHIP(2),
TRANSPORT(2);
private int count;
public int deckRand;
Cards(int count) {
this.count = count;
}
public int getCount() {return count;}
}
class Card {
public Cards type;
Card(Cards type){
this.type = type;
}
public Cards getType() {
return type;
}
}
class CardDeck { // construct a deck
List<Card> deck;
CardDeck() { // constructor
deck = new ArrayList<Card>();
for (Cards type : Cards.values()) {
for(int i=0;i<type.getCount();i++){
deck.add(new Card(type));
}
}
System.out.println(deck);
Collections.shuffle(deck);
for (Card element : deck)
System.out.println(element);
}
}
public class GalCivMain extends JFrame {.......................
I have here an enum. In main class I need to find out if the card on FE. 12th place is ENERGY or not. And I also don't know, how to write it (I mean how to write if the card on 12th place is ENERGY, do sth.. Could anyone help me pls? Thanks for reacting.


LinkBack URL
About LinkBacks
Reply With Quote