Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Box{
- private int w;
- private int h;
- private int d;
- /*public int getW(){
- return w;
- }
- public void setW(int w){
- this.w=w;
- }
- public void setH(int h){
- this.h=h;
- }
- public int getH(){
- return h;
- }
- public void setD(int d){
- this.d=d;
- }
- public int getD(){
- return d;
- }
- */
- Box(){}
- Box(int w,int h,int d){
- this.w=w;
- this.h=h;
- this.d=d;
- }
- Box(Box box){
- w=box.w;
- h=box.h;
- d=box.d;
- }
- double vol(){
- return w*h*d;
- }
- }
- class Weight extends Box{
- int weight;
- double vol;
- Weight(int w,int h,int d, int wt){
- super(w,h,d);
- /*Box b3=new Box();
- b3.setD(d);
- b3.setH(h);
- b3.setW(w);
- Box b4=new Box(b3);
- */
- weight=wt;
- }
- }
- public class Examle6 {
- public Examle6() {
- }
- public static void main(String[] args) {
- // Box b=new Box(10,20,30);
- /* Box b=new Box();
- b.w=10;
- b.h=20;
- b.d=30;
- b.setD(30);
- b.setH(20);
- b.setW(10);
- Box b1=new Box(b);
- System.out.println("Width: "+b.getW());
- System.out.println("Height: "+b.getH());
- System.out.println("Depth: "+b.getD());*/
- // System.out.println("Volume: "+b.vol());
- Weight ww=new Weight(4,5,6,7);
- System.out.println("New Volume: "+ww.vol());
- System.out.println("Weight: "+ww.weight);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment