Practice set ch10
package com.company;
class Rectangle{
public double getLength() {
return length;
}
public void setLength(double length) {
this.length = length;
}
public double getBreadth() {
return breadth;
}
public void setBreadth(double breadth) {
this.breadth = breadth;
}
public double length;
public double breadth;
public Rectangle(int l,int b){
this.length=l;
this.breadth=b;
System.out.println(length);
System.out.println(breadth);
}
public double area(){
return length*breadth;
}
public double perimeter(){
return 2*(length+breadth);
}
}
class cuboid extends Rectangle{
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public double height;
public cuboid(int x,int y,int z) {
super(x, y);
this.height = z;
System.out.println(length+breadth+height);
}
public double volume(){
return length*breadth*height;
}
}
//class circle1{
// public int r;
// public circle1(){
// System.out.println("hello non para");
// }
// public circle1(int r){
// this.r=r;
// System.out.println(" I am circle with parameter with "+r);
// }
// public double area(){
// return Math.PI*r*r;
// }
// public double perimeter(){
// return 2*Math.PI*r;
// }
//}
//class cylinder1 extends circle1{
// public int height;
// public cylinder1(int r,int h){
// super(5);
// this.height=h;
// System.out.println("I am cylinder with radius "+r);
// }
// public double volume(){
// return Math.PI*r*r*height;
// }
//}
public class CWH_52_Chapter_10_ps {
public static void main(String[] args) {
// Problem 1
// circle1 obj1=new circle1(5);
// cylinder1 obj=new cylinder1(51,6);
//
// Problem 2
Rectangle obj= new Rectangle(4,5);
cuboid obj1= new cuboid(2,4,6);
}
}
Comments
Post a Comment