我的黑杰克程序有错误。我已经尝试了半个小时来找出答案。它说“类型卡已定义”。由于某种原因,我的 deal() 函数也无法正常工作。我再次发布此信息并提供更多信息。有人可以帮忙吗?我是初学者。所以我有一个名为 index 的类,其主要方法是:
public static void main(String[] args){
runGame(2);
}
然后我有一些方法,然后我有 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);
}
在那个文件夹中,我还有一个 Card.class 和 Deck.class: 如果你想看我有下面的链接。当我运行它时,我收到一个错误,我不知道我做了什么,但它改变了:
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)
但由于某种原因,这次我收到了这个错误:
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)
谁能帮帮我吗。
index.java:http://pastebin.com/8x344TN9 Card.java:http://pastebin.com/NLbHBDSi Deck.java:http://pastebin.com/emD75yv0 _ _