Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Could someone look at this error.

807606May 14 2007 — edited May 14 2007
Here are the errors:
Compiling 1 source file to C:\Documents and Settings\James Kovacs\JavaGin\build\classes
C:\Documents and Settings\James Kovacs\JavaGin\src\App.java:76: local variable playerHand is accessed from within inner class; needs to be declared final
                playerHand = DrawCardHandChange(playerHand, DrawCardDiscard(_discardPile));  //should add card from discard to hand
C:\Documents and Settings\James Kovacs\JavaGin\src\App.java:76: local variable playerHand is accessed from within inner class; needs to be declared final
                playerHand = DrawCardHandChange(playerHand, DrawCardDiscard(_discardPile));  //should add card from discard to hand
C:\Documents and Settings\James Kovacs\JavaGin\src\App.java:76: local variable _discardPile is accessed from within inner class; needs to be declared final
                playerHand = DrawCardHandChange(playerHand, DrawCardDiscard(_discardPile));  //should add card from discard to hand
C:\Documents and Settings\James Kovacs\JavaGin\src\App.java:77: local variable _discardPile is accessed from within inner class; needs to be declared final
                _discardPile = DrawCardDiscardChange(_discardPile);  //take top card from discard
C:\Documents and Settings\James Kovacs\JavaGin\src\App.java:77: local variable _discardPile is accessed from within inner class; needs to be declared final
                _discardPile = DrawCardDiscardChange(_discardPile);  //take top card from discard
5 errors
BUILD FAILED (total time: 0 seconds)
Here is the code:
public class App extends javax.swing.JFrame {
    
    /** Creates new form App */
    public App() {
        initComponents(); //creates original state of GUI
        getContentPane().setBackground(new Color(0,102,0)); //paints the ContentPane to match the GUI
        
        int[] _suitDeck = {0,                                           //card number in array corresponds to suit number
                           1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,     //1 = clubs, 2 = spades, 3 = hearts, 4 = diamonds
                           1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,
                           1,2,3,4,1,2,3,4,1,2,3,4};
        
        int[] _cardDeck = GenerateDeck();  //generates an initial deck
        String[] CONVERTED_cardDeck = ConvertDeck(_cardDeck);  //creates a deck where cards are named
       
        System.out.println("*****ORIGINAL DECK*****");
        for (int j=1; j<_cardDeck.length; j++) {System.out.println(j + ". " + CONVERTED_cardDeck[j]);}  //print the original deck
        
        int[] playerHand = DrawHand(_cardDeck);  //draws a hand for the player
        _cardDeck = DrawHandDeckChange(_cardDeck);  //changes deck by taking out player hand
        CONVERTED_cardDeck = ConvertDeck(_cardDeck);  //updates named deck to print
        
        System.out.println("*****FIRST NEW DECK*****"); 
        for (int j=1; j<_cardDeck.length; j++) {System.out.println(j + ". " + CONVERTED_cardDeck[j]);}  //prints named deck
        
        int[] compHand = DrawHand(_cardDeck);  //draws a hand for the computer
        _cardDeck = DrawHandDeckChange(_cardDeck);  //changes deck by taking out computer hand
        CONVERTED_cardDeck = ConvertDeck(_cardDeck);  //updates named deck to print
        
        System.out.println("*****SECOND NEW DECK*****");
        for (int j=1; j<_cardDeck.length; j++) {System.out.println(j + ". " + CONVERTED_cardDeck[j]);}  //prints named deck
        
        String[] CONVERTED_playerHand = ConvertDeck(playerHand);  //creates a named player hand
        String[] CONVERTED_compHand = ConvertDeck(compHand);  //creates a named computer hand
        
        System.out.println("*****PLAYER HAND*****");        
        for (int j=1; j<playerHand.length; j++) {System.out.println(j + ". " + CONVERTED_playerHand[j]);}  //prints player hand
        DisplayHand(playerHand, jButton1, jButton2, jButton3, jButton4, jButton5, jButton6, jButton7, jButton8);  //sets button icons of player hand
       
        System.out.println("*****COMPUTER HAND*****");        
        for (int j=1; j<compHand.length; j++) {System.out.println(j + ". " + CONVERTED_compHand[j]);} //prints computer hand
        
        jButton10.setIcon(new javax.swing.ImageIcon("C:\\Documents and Settings\\James Kovacs\\JavaGin\\" + DrawCardDeck(_cardDeck) + "_big.gif"));  //sets button icon for discard pile with top card from deck
        
        int[] _discardPile = new int[2]; //creats discard pile array
        _discardPile[1] = DrawCardDeck(_cardDeck);  //adds top card from deck to discard pile
        _cardDeck = DrawCardDeckChange(_cardDeck);  //updates deck by taking top card        
        CONVERTED_cardDeck = ConvertDeck(_cardDeck);  //updates nameds deck
        
        System.out.println("*****DRAWN FROM DECK*****");
        for (int j=1; j<_cardDeck.length; j++) {System.out.println(j + ". " + CONVERTED_cardDeck[j]);} //prints drawfrom deck
        
        jButton10.addActionListener(new ActionListener( ) {
            public void actionPerformed(ActionEvent ev) {
                playerHand = DrawCardHandChange(playerHand, DrawCardDiscard(_discardPile));  //should add card from discard to hand
                _discardPile = DrawCardDiscardChange(_discardPile);  //take top card from discard
            }
        });

    }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 11 2007
Added on May 14 2007
11 comments
111 views