You are on page 1of 2

class Room

{
float length,width,height;
byte nWindows;
static int totWindows;

Room(){};
Room (float l,float w,float h,byte n)
{
length=1;width=w;height=h;
nWindows=n;totWindows+=n;
}
Room(float 1,float w)
{
length=l;width=w;height=10;
nWindows=2; totWindows++;
}
double area()
{
return(length*height);
void display()
{
system.out.println("\nLength:"+length+"\nWidth"+width);
system.out.println("Heigth:"+heigth);
system.out.println("Windows:"+nwindows);
}
}
}

class Classroom extends Room


{
int nBenches,nSeatsBench;
Classroom(){};
Classroom(float l,float w,float h,byte n,int nB,int nSB)
{
super(l,w,h,n);
nBenches=nB;nSeatsBench=nSB;
}
void show()
{
super.display();
system.out.println("Benches:"+nBenches);
system.out.println("Seats per Bench:"+nSeatBench);
system.out.println("Total Seats in a class:"+getSeats());
}
void display()
{
system.out.println("\nClassroom with
length:"+length+"feet,width"+width+"feet"+nBenches+"Benches,each to
accmodate"+"nSeatBeTotal seat in a Class is"+getSeats());
}
int getSeats(){return nBenches*nSeatsBench;}
}

class inheritance
{
public static void main(String args[])
{
Room r1=new Room(20,15,10,(byte)2);
r1.display();
Classroom cr1=new Classroom(30,20,12,(byte)3,21,3);
cr1.show();
system.out.println("Area of classroom1 is "+cr1.area()+"square feet");
cr2.display();
system.out.println("\nTotal number of Windows:"+Room.totWindows);
}

You might also like