samuel34

Untitled

Mar 13th, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. package sam.male;
  2.  
  3. public class Box {
  4. double length;
  5. double width;
  6. double height;
  7. Box(double x,double y,double z){
  8. length=x;
  9. width=y;
  10. height=z;
  11. }
  12. Box(Box b){
  13. length=b.length;
  14. width=b.width;
  15. height=b.height;
  16. }
  17. Box(double leng){
  18. length=width=height;
  19. }
  20. Box(){
  21. height=1;
  22. width=1;
  23. length=1;
  24.  
  25. }
  26. double vol() {
  27. return length*width*height;
  28.  
  29. }
  30. double area(){
  31. return length*width;
  32. }
  33.  
  34. }
  35. class Bweight extends Box{
  36. double weight;
  37. Bweight(Bweight b){
  38. super(b);
  39. weight=b.weight;
  40. }
  41. Bweight(double x, double y,double z,double a){
  42. super(x,y,z);
  43. weight=a;}
  44. Bweight(){
  45. super();
  46. weight=1;
  47. }
  48. Bweight(double leng, double a){
  49. super(leng);
  50. weight=a;
  51. }
  52.  
  53.  
  54. static class Demo {
  55. public static void main (String args[]){
  56. Bweight wei = new Bweight(3,4,5,7);
  57. double vol;
  58. vol=wei.vol();
  59. System.out.print(vol);
  60. }
  61.  
  62.  
  63. }}
Advertisement
Add Comment
Please, Sign In to add comment