找不到标志

时间:2014-04-06 20:04:49

标签: java

到目前为止,根据我一直在阅读的内容,我的错误与我的主要课程无法访问我的juego课程有关。我无法实例化" juego"也不是" tablero"类对象。我该如何解决这个错误?我确定它一定是我忽视的东西,但我还没能弄清楚。

我绊倒了一个错误,上面写着:

C:\Users\PabloEugenio\Desktop\Memoria\GameDriver.java:7: error: cannot find symbol
public class GameDriver extends juego{
                                ^
  symbol: class juego
C:\Users\PabloEugenio\Desktop\Memoria\GameDriver.java:10: error: cannot find symbol
        juego j; 
        ^
  symbol:   class juego
  location: class GameDriver
C:\Users\PabloEugenio\Desktop\Memoria\GameDriver.java:11: error: cannot find symbol
        j = new juego();
                ^
  symbol:   class juego
  location: class GameDriver
3 errors
[Finished in 0.5s with exit code 1]

该程序包含Memoria包中的三个java类; juego.java,tablero.java和GameDriver.java。

//GameDriver

// 
//      cd C:\Users\PabloEugenio\Desktop\Memoria
//
package Memoria;
public class GameDriver extends juego{
    public static void main(String []args){

        juego j; 
        j = new juego();

    }
}

这是我的juego课程:

//Class Juego

package Memoria; 

public class juego{

    int[][] tab;
    int count;
    int aux, x, y; 
    int comp; 

    public juego(){
        count = 1;
        comp = 0;
        //Initialize it
        int[][] tab = {{1,1,2,2},{3,3,4,4},{5,5,6,6},{7,7,8,8}};
        //Shuffles the array 
        for(int k=0; k<2;k++){
        for(int i=0; i<4;i++){
            for(int j=0; j<4; j++){
                x = (int)(Math.ceil(Math.random()*3));
                y = (int)(Math.ceil(Math.random()*3));
                aux = tab[i][j];
                tab[i][j] = tab[x][y];
                tab[x][y] = aux; 
            }
        }
        }        

        //Output array 

        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){        
                System.out.println(tab[i][j]);
            }
        }

    }//Ends juego

    //Returns a value in the array
    public int getValue(int x, int y){
        return tab[x][y]; 
    }//getValue ends

    //nullify
    //Gives a zero value to the coordinate in the array 
    public void nullify(int x, int y){
        tab[x][y]=0;
    }//nullify ends


}

这是我的tablero类:

package Memoria; 

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


public class tablero extends JFrame{
    //Declare ImageIcons, Labels, and Frames 
    ImageIcon back, carta1, carta2, carta3, carta4, carta5, carta6, carta7, carta8;
    JLabel l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16;   
    JFrame frame;

    public void tablero(){
        frame = new JFrame("Memoria!");
        // Initialize ImageIcons to put them later in labels
        back=new ImageIcon("Images/back.gif");
        carta1=new ImageIcon("Images/carta1.gif");  
        carta2=new ImageIcon("Images/carta2.gif");
        carta3=new ImageIcon("Images/carta3.gif");
        carta4=new ImageIcon("Images/carta4.png");
        carta5=new ImageIcon("Images/carta5.gif");
        carta6=new ImageIcon("Images/carta6.gif");
        carta7=new ImageIcon("Images/carta7.png");
        carta8=new ImageIcon("Images/carta8.gif");
        //Initialize labels with no text on 'em
        l1=new JLabel("");
        l2=new JLabel("");
        l3=new JLabel("");
        l4=new JLabel("");
        l5=new JLabel("");
        l6=new JLabel("");
        l7=new JLabel("");
        l8=new JLabel("");
        l9=new JLabel("");
        l10=new JLabel("");
        l11=new JLabel("");
        l12=new JLabel("");
        l13=new JLabel("");
        l14=new JLabel("");
        l15=new JLabel("");
        l16=new JLabel("");
        //GridLayout de 4x4 and add labels to frame
        frame.setLayout(new GridLayout(4,4));
        frame.setSize(800, 800);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);

        frame.add(l1);
        frame.add(l2);
        frame.add(l3);
        frame.add(l4);
        frame.add(l5);
        frame.add(l6);
        frame.add(l7);
        frame.add(l8);
        frame.add(l9);
        frame.add(l10);
        frame.add(l11);
        frame.add(l12);
        frame.add(l13);
        frame.add(l14);
        frame.add(l15);
        frame.add(l16);
    }

}

0 个答案:

没有答案