I have trouble converting r [rank] to string. Eclipse keeps saying that he needs to solve the array besides card [13 * I + J] = New card (I, J) is having trouble with; It just keeps saying that a variable can not be solved. This is my code ...
public class card {private string suit; Private string rank; Private static string [] s = {"heart", "hook", "diamond", "club"}; Private String String [] R = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack ", "Queen King" }; Public card (int suite, int deck) {for (int i = 0; i & lt; 4; i ++) {for (int j = 0; j and lt; 13; j ++) {card [ 13 * I + J] = New card (I, J); }}} Public card (string r, string s, string suit) {for (rank = 0; rank & lt; r.length (); rank + = 1) {if (rank.equals (r [rank] )) {This.rank = r + 1; }} This.suit = suite; } Public string getSuit () {return suit; } Public Zero Setset (string A, string suit) {this.suit = suit; } Public string getRank () {returns rank; } Public Zero Sitank (String S, String Rank) {this.rank = rank; } Public string toString () {return String.valueOf (this.getRank ()) + String.valueOf (this.getSuit (.) CharAt (0)); }} public square deck
personal card [] deck; Private int deck; Private finals ii SIZE_OF_DECK = 52; Private int presentcards; Public deck () {deck = new card [deck]; } Private Zero init () {} Public Zero Alteration (int no) {int i, j, k; For (k = 0; k & lt; num; k ++) {i = (int) (SIZE_OF_DECK * Math.random () * 100); J = (int) (SIZE_OF_DECK * math.rendum () * 100); Card tmp = deck [ii]; Deck [i] = deck [ja]; Deck [j] = tmp; } Current card = 0; } Public card together () (if (current card & lt; SIZE_OF_DECK) {return deck [current card ++];} Else {System.out.print ("out of card error"); return tap;}} public integer Total Card () {return SIZE_OF_DECK;} }
You never start your card array any time ... Before creating each individual object with each of your loops, try something on the lines of this card [] card = new card [52];
No comments:
Post a Comment