Arush22

Untitled

Dec 18th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. package com.suarez;
  2.  
  3. public class Box
  4. {
  5.  
  6. private int width;
  7. private int length;
  8. public Box() //Default constructor
  9. {
  10. width =1;
  11. length =1;
  12. }
  13. public Box(int width1, int length1)
  14. {
  15. width = width1;
  16. length = length1;
  17. }
  18. public void setWidth(int width1)
  19. {
  20. width = width1;
  21. }
  22. public void setLength(int length1)
  23. {
  24. length = length1;
  25. }
  26. public int getWidth()
  27. {
  28. return width;
  29. }
  30. public int getLength()
  31. {
  32. return length;
  33. }
  34.  
  35. public int CalulateArea()
  36. {
  37. return (width*length);
  38. }
  39. public int CalculateVolume(int height)
  40. {
  41. return (height*width*length);
  42. }
  43. public void toString(int area, int volume)
  44. {
  45. System.out.println("Area = "+area+" Volume = "+volume);
  46. }
  47. }
Add Comment
Please, Sign In to add comment