Bulimic, i dont knows if is right to calculate cilindro`s and circulo´s area 
and perimetro. I dont renember how to do it.... i must take a book for 
renember...jejjejej
 

 

 

 

 

 

 

 

 
> Date: Mon, 30 Mar 2009 14:32:33 -0700
> Subject: [java programming] Re: Logic error!
> From: [email protected]
> To: [email protected]
> 
> 
> On Mar 31, 3:27 am, el mio uno y dos <[email protected]> wrote:
> > 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.
> Hello. I did not receive any copy. Anyway, we can discuss here.
> 
> Circulo inherits cilindro is odd. I think it would be more efficient
> if cilindro extends circulo as it can take advantage of code re-use.
> For example:
> public class Circulo{
> public double area(double radius){
> }
> public double perimetro(double radius){
> }
> }
> 
> public class Cilindro extends Circulo{
> public double area(double radius, double height){
> // Use circulo's methods to calculate cilindro's area. Then
> return.
> double areaCirculo=area(radius), perimetroCirculo=perimetro
> (radius);
> }
> }
> >
> >
> >
> > > 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
> 
> > 

_________________________________________________________________
Llévate Messenger en el móvil a todas partes ¡Conéctate!
http://www.microsoft.com/spain/windowsmobile/messenger/default.mspx
--~--~---------~--~----~------------~-------~--~----~
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