java - How would i do "Box entends Cube" -


i want extend cube box. program has 3 parts first rectangle class use extend box class extend cube. stuck @ cube part. instructions :

assessment instructions a. cube box length, width, , height have same values. b. won’t have add additional instance variables or methods, have set cube’s constructor ensure length, width, , height have same values.

rectangle:

    public class rectangle     {         // instance variables          private int length;         private int width;          /**          * constructor objects of class rectangle          */         public rectangle(int l, int w)         {             // initialise instance variables             length = l;             width = w;         }          // return height         public int getlength()         {             return length;         }         public int getwidth()         {             return width;         }      } 

box:

public class box extends rectangle {     // instance variables      private int height;      /**      * constructor objects of class box      */     public box(int l, int w, int h)     {         // call superclass         super(l, w);         // initialise instance variables         height = h;     }      // return height     public int getheight()     {         return height;     }  } 

and main 1 cube:

class cube extends box{     // instance variables      private int height;         private int length;     private int width;      public cube(int h,int w,int l){         super(h,w,l);      }      public double getheight(){         return height;                 }         public double getlength() {             return length;         }          public double getwidth() {             return width;         } } 

i need know if did cube 1 right or not. if didn't right please me fix it.

a cube box sides equal. pass same length parameter 3 dimensions of box.

public class cube extends box{     public cube(int length)     {         super(length, length, length);     } } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -