I have an error in my black jack program. I have been trying for half an hour to find out. it says “The type Card is already defined”. and for some reason my deal() function is not working as well. I am posting this again with more information. Can anyone please help? I am a beginner.
So i have an class named index whose main method is:
public static void main(String[] args){
runGame(2);
}
Then i have a few methods and then i have runGame:
public static void runGame(int n){
Card[] newdeck=createCardArray();
Card[] shuffleddeck = shuffle(newdeck);
Deck deck = new Deck(shuffleddeck);
int[] players = createPlayers(n);
int[] points = createPoints(n);
for(int i = 0 ; i< players.length - 1; i++){
Card a = deck.deal();
Card b = deck.deal();
updatePoints(players, points, i, a);
updatePoints(players, points, i, b);
}
printPlayersPoints(players, points);
}
In that folder i also have a Card.class and Deck.class: If you want to look i have the links below.
When i run this i get an error i dont know what i did but it changed:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The public type Deck must be defined in its own file
Syntax error on token "}", { expected
Syntax error on token(s), misplaced construct(s)
The public type Card must be defined in its own file
Syntax error on tokens, delete these tokens
The public type Blackjack must be defined in its own file
Syntax error on token "]", invalid (
Syntax error, insert "]" to complete ArrayAccess
Syntax error, insert ")" to complete MethodInvocation
Syntax error, insert ";" to complete Statement
GIO cannot be resolved
GIO cannot be resolved
GIO cannot be resolved
BlackjackWindow cannot be resolved to a type
BlackjackWindow cannot be resolved to a type
GIO cannot be resolved
BlackjackWindow cannot be resolved to a type
Syntax error on token "}", { expected
Syntax error on token(s), misplaced construct(s)
The public type Hand must be defined in its own file
Syntax error on tokens, delete these tokens
The public type Player must be defined in its own file
Syntax error, insert "}" to complete Block
BlackjackWindow cannot be resolved to a type
BlackjackWindow cannot be resolved to a type
GIO cannot be resolved
GIO cannot be resolved
BlackjackWindow cannot be resolved to a type
GIO cannot be resolved
GIO cannot be resolved
GIO cannot be resolved
GIO cannot be resolved
GIO cannot be resolved
Syntax error on token "}", { expected
Syntax error on tokens, delete these tokens
Syntax error, insert "}" to complete Block
Syntax error, insert "}" to complete ClassBody
at Card.<init>(fullblk.java:4)
at index.createCardArray(index.java:19)
at index.runGame(index.java:104)
at index.main(index.java:3)
But for some reason this time i am getting this error:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The constructor Deck(Card[]) is undefined
The method deal() is undefined for the type Deck
The method deal() is undefined for the type Deck
at index.runGame(index.java:101)
at index.main(index.java:3)
Can anyone please help me.
index.java: http://pastebin.com/8x344TN9
Card.java: http://pastebin.com/NLbHBDSi
Deck.java:http://pastebin.com/emD75yv0
Brace Problem at end of deck class: