Ir para conteúdo
Fórum Script Brasil
  • 0

Erro ao compilar um programa


OkumuraRIn123

Pergunta

escrevi este código ele apresenta um erro quando tento compilar

// DuasBolas.java

public class DuasBolas {
    public static void main(String args[]) {
        // Instanciando um objeto
        DuasBolas bola1 = new DuasBolas();
        //Armazenando valores nos atributos do objeto
        bola1.raio = 0.34f;
        bola1.oca = false;
        bola1.cor = 10;
        bola1.material= 33;
        // Instanciando um outro objeto 
        DuasBolas bola2 = new DuasBolas();
        // Armazenando valores nos atributos do outro objeto 
        bola2.oca = true;
        bola2.material = bola1.material;
        // Usando valores armazenado
        bola2.raio = 5 * bola1.raio;
        bola2.material = bola1.cor+1;
        System.out.println("Bola1 : ");
        System.out.println(" raio = " + bola1.raio );
        System.out.println(" oca = " + bola1.oca );
        System.out.println(" cor = " + bola1.cor );
        System.out.println("Bola2 : ");
        System.out.println(" raio = " + bola2.raio );
        System.out.println(" oca = " + bola2.oca );
        System.out.println(" cor = " + bola2.cor );
    }
}

este é o erro

.\DuasBolas.java:8: error: cannot find symbol
                bola1.raio = 0.34f;
                     ^
  symbol:   variable raio
  location: variable bola1 of type DuasBolas
.\DuasBolas.java:9: error: cannot find symbol
                bola1.oca = false;
                     ^
  symbol:   variable oca
  location: variable bola1 of type DuasBolas
.\DuasBolas.java:10: error: cannot find symbol
                bola1.cor = 10;
                     ^
  symbol:   variable cor
  location: variable bola1 of type DuasBolas
.\DuasBolas.java:11: error: cannot find symbol
                bola1.material= 33;
                     ^
  symbol:   variable material
  location: variable bola1 of type DuasBolas
.\DuasBolas.java:15: error: cannot find symbol
                bola2.oca = true;
                     ^
  symbol:   variable oca
  location: variable bola2 of type DuasBolas
.\DuasBolas.java:16: error: cannot find symbol
                bola2.material = bola1.material;
                     ^
  symbol:   variable material
  location: variable bola2 of type DuasBolas
.\DuasBolas.java:16: error: cannot find symbol
                bola2.material = bola1.material;
                                      ^
  symbol:   variable material
  location: variable bola1 of type DuasBolas
.\DuasBolas.java:18: error: cannot find symbol
                bola2.raio = 5 * bola1.raio;
                     ^
  symbol:   variable raio
  location: variable bola2 of type DuasBolas
.\DuasBolas.java:18: error: cannot find symbol
                bola2.raio = 5 * bola1.raio;
                                      ^
  symbol:   variable raio
  location: variable bola1 of type DuasBolas
.\DuasBolas.java:19: error: cannot find symbol
                bola2.material = bola1.cor+1;
                     ^
  symbol:   variable material
  location: variable bola2 of type DuasBolas
.\DuasBolas.java:19: error: cannot find symbol
                bola2.material = bola1.cor+1;
                                      ^
  symbol:   variable cor
  location: variable bola1 of type DuasBolas
.\DuasBolas.java:21: error: cannot find symbol
                System.out.println(" raio = " + bola1.raio );
                                                     ^
  symbol:   variable raio
  location: variable bola1 of type DuasBolas
.\DuasBolas.java:22: error: cannot find symbol
                System.out.println(" oca = " + bola1.oca );
                                                    ^
  symbol:   variable oca
  location: variable bola1 of type DuasBolas
.\DuasBolas.java:23: error: cannot find symbol
                System.out.println(" cor = " + bola1.cor );
                                                    ^
  symbol:   variable cor
  location: variable bola1 of type DuasBolas
.\DuasBolas.java:25: error: cannot find symbol
                System.out.println(" raio = " + bola2.raio );
                                                     ^
  symbol:   variable raio
  location: variable bola2 of type DuasBolas
.\DuasBolas.java:26: error: cannot find symbol
                System.out.println(" oca = " + bola2.oca );
                                                    ^
  symbol:   variable oca
  location: variable bola2 of type DuasBolas
.\DuasBolas.java:27: error: cannot find symbol
                System.out.println(" cor = " + bola2.cor );
                                                    ^
  symbol:   variable cor
  location: variable bola2 of type DuasBolas
17 errors
error: compilation failed

Poderiam me ajudar? já fiz de td e não consegui resolver
        

Editado por OkumuraRIn123
esqueci uma parte
Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...