Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

program based on inheritance

  Asked By: Durril    Date: May 18    Category: Java    Views: 1444
  

I was writing a program based on inheritance and i get 2
error messages on compiling (cannot resolve symbol).Can somebody
please explain what's wrong and if iam using super wrongly?
Thanks.
class Rec
{
double len;
double wid;
Rec(Rec r)
{
len=r.len;
wid=r.wid;
}
Rec(double l, double w)
{
len = l;
wid =w;
}
Rec()
{
len= 1;
wid = 1;
}

double area()
{
return len*wid;
}
}
class Cuboid extends Rec
{
double ht;
Cuboid(Cuboid cb)
{
super(cb);
ht=cb.ht;
}
Cuboid(double l, double w,double h)
{
super(l,w);
ht=h;
}
Cuboid()
{
super();
ht=1;
}


}
class DemoCuboid
{
public static void main(String args[])
{
Cuboid c1= new Cuboid(10,20);
Cuboid c2= new Cuboid(150.4,120.4);
Cuboid c3= new Cuboid();
Cuboid c5= new Cuboid(c1);

double ar;

ar=c1.area();
System.out.println("Area of c1"+ar);
System.out.println("Height of c1"+c1.ht);

ar=c2.area();
System.out.println("Area of c2"+ar);
System.out.println("Height of c2"+c2.ht);

ar=c3.area();
System.out.println("Area of c3"+ar);
System.out.println("Height of c3"+c3.ht);



ar=c5.area();
System.out.println("Area of c5"+ar);
System.out.println("Height of c5"+c5.ht);

}
}

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on program based on inheritance Or get search suggestion and latest updates.




Tagged: