3
In my project I have the class main
and created new Java class files with Netbeans to define the objects there.
I can only use in main
one of the classes, the others I can’t even call the methods.
Is that right? I can only use main
an archive .java
class? What if I need more classes?
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package iniciativa13ªera;
/**
*
* @author Giovane
*/
public class Iniciativa13ªEra {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Jogador giovane = new Jogador();
giovane.setNomeJogador("Giovane - Ekth");
giovane.setModDestreza(3);
giovane.setModTamanho(0);
giovane.calcular();
}
}
This is my main, and below the first class I made
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package iniciativa13ªera;
/**
*
* @author Giovane
*/
public class Jogador {
//Atributos
String nomeJogador;
int modTamanho;
int modDestreza;
//------------- Métodos Personalizados
//Muda o nome do Objeto (jogador)
public void nome (String nome){
this.setNomeJogador(nome);
}
//Muda o tamanho do Objeto (jogador)
public void tamanho(int valor){
this.setModTamanho(valor);
}
//Muda a destreza do Objeto (jogador)
public void destreza(int valor){
this.setModDestreza(valor);
}
//--------------- Métodos Especiais
public String getNomeJogador() {
return nomeJogador;
}
public void setNomeJogador(String nomeJogador) {
this.nomeJogador = nomeJogador;
}
public int getModTamanho() {
return modTamanho;
}
public void setModTamanho(int modTamanho) {
this.modTamanho = modTamanho;
}
public int getModDestreza() {
return modDestreza;
}
public void setModDestreza(int modDestreza) {
this.modDestreza = modDestreza;
}
//---------------- Métodos Construtor
public Jogador() {
this.setModTamanho(0);
this.setModDestreza(0);
}
And for example, if I try to pull a second, which I have done there, in another .java
, doesn’t work, like that giovane.calcular()
which is defined in a third class
Puts your code and shows where errors occur?
– gato
Whoa, just a second, I’ll organize
– Giovane Machado
@Giovanemachado puts the code in the question then select it and click the button
{}
Code sample, that serves to format.– gato
@Giovanemachado you can use in
main
or in the class that contains this method, all classes that are within the packageiniciativa13ªera
. Is the package name right? Usually you don’t use symbols or letters with accents to name packages. Yours could look like thisIniciativa13
orIniciativaTreze
, letter-only.– gato
I suffered but I edited. That’s right, I can change but I don’t think it solves the problem
– Giovane Machado
the error appears as cannot find a Symbol
– Giovane Machado
I checked, the package is the same. I created the classes by clicking on it, there is no different
– Giovane Machado
@Giovanemachado tried to remove the symbol
ª
of the package name?– gato
I have removed, also noticed there that appears now "Error while doing Parsing the file", referring to this problem I am trying to solve. Changing the package name was unsuccessful
– Giovane Machado