2012-11-19 6 views
-2

검은 색 잭 프로그램에 오류가 있습니다. 나는 30 분 동안 알아 내려고 노력했다. 그것은 "유형 카드가 이미 정의되어 있습니다"라고 말합니다. 어떤 이유로 내 deal() 함수가 제대로 작동하지 않습니다. 나는 이것을 더 많은 정보와 함께 다시 올리고있다. 아무도 도와 줄 수 있습니까? 나는 초보자이다.검은 색 잭 게임 오류

다음
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

+1

은 당신이 발생하고있는 컴파일 오류를 조사하는 것이 좋습니다. – Vulcan

+1

[카드 게임 오류 발생] (http://stackoverflow.com/questions/13446069/making-a-card-game-error)의 Tidier 중복 원본 질문을 편집하는 것이 더 좋을 것입니다. 새 질문을 열어 중복 된 질문을 닫으십시오. 이미 제공된 조언에 유의하십시오. –

답변

2

브레이스 문제 :

public class Deck 
{ 
    // your constructors and methods. 
    } 
} 
+0

알아 들었어! 그게 문제 였어. – user1796681

0

가 아니라, 당신이 당신의 갑판 클래스의 끝에 추가 } (닫는 중괄호)가, 그 닫는 중괄호에게 컴파일을 제거합니다. 너는 잘해야한다.

public class Deck 
{ 
    // your constructors and methods. 
    } 
} 
+0

고마워,하지만 나는 그 문제가 여전히 유일한 문제라고 생각하지 않는다. – user1796681

+0

@ user1796681 지금 오류가 무엇입니까? ? – PermGenError

+0

데크 클래스를 제거하여 문제가 해결되었습니다. – user1796681

1

Deck.java의 끝에 추가로 중괄호 ('}')가 있습니다. 갑판 클래스의 끝에서