Hello bulimic, i think that circulo is not a inner class of cilindro. I think 
that circulo is a subclass of cilindro. I send a copy of how i do it. Please 
see it and tell me if is correct.
 
> Date: Mon, 30 Mar 2009 11:53:33 -0700
> Subject: [java programming] Re: Logic error!
> From: [email protected]
> To: [email protected]
> 
> 
> On Mar 31, 1:36 am, jose luis garcia <[email protected]> wrote:
> > *Hello everybody... I have a problem. I wrote a code for a program that have
> > 1 superclass and 1 class extends. the code it`s follow:*
> >
> > //Programa que realiza algunos calculos mediante las caracteristicas de un
> > cilindro
> >
> > package cilindro;
> >
> > // @author louis
> >
> > import java.util.Scanner;
> >
> > public class Cilindro {
> >      double pi = Math.PI;
> >
> >    public Cilindro(){
> >       // super();
> >
> >     }
> >
> >     public double areaCilindro(double r, double h){
> >         double area = (2*pi*r*h) + (2*pi*r*r);
> >
> >         return area;
> >     }
> >
> >     public double perimetroCilindro(double r, double h){
> >         double perimetro = (4*pi*r)+(2*h);
> >
> >         return perimetro;
> >
> >     }
> >
> >     public class Circulo extends Cilindro{
> >
> >         Circulo(){
> >             super();
> >         }
> >
> >         public double areaCirculo(double r){
> >
> >             double area = pi*r*r;
> >             return area;
> >         }
> >
> >         public double perimetroCirculo(double r){
> >             double perimetro = 2*pi*r;
> >
> >             return r;
> >         }
> >
> >     }
> >
> >         public static void main(String[] args) {
> >
> >            // Cilindro obj = null;
> >             Circulo obj1 = null;
> I suspect the culprit is the inner class. If I remember correctly, an
> inner class type declaration should be like:
> Cilindro.Circulo obj1 = null;
> 
> >             double radio = 0,altura = 0;
> >             Scanner input = new Scanner(System.in);
> >
> >             System.out.println("Ingresa Radio: ");
> >             radio = input.nextFloat();
> >
> >            /* System.out.println("Ingresa altura: ");
> >             altura = input.nextFloat();
> >             */
> >             String resultado = "Area del circulo: " +
> > obj1.areaCirculo(radio);
> >
> >             System.out.println(resultado);
> >
> >     }
> >
> > }
> >
> > *Netbeans not generate any error. But at the moment that run the program and
> > insert a float, Netbeans generate me this message:*
> >
> > run:
> > Ingresa Radio:
> > Exception in thread "main" java.lang.NullPointerException
> >         at cilindro.Cilindro.main(Cilindro.java:66)
> > 2.23
> > Java Result: 1
> > GENERACIÓN CORRECTA (tiempo total: 3 segundos)
> >
> > *
> > I`m sure that is a logic error... help me please. Thanks!
> > *
> 
> > 

_________________________________________________________________
Descubre todas las formas en que puedes estar en contacto con amigos y 
familiares.
http://www.microsoft.com/windows/windowslive/default.aspx
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to