Advertisement
mmayoub

Box.java

Jan 28th, 2023
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. package proj27012023;
  2.  
  3. public class Box {
  4.     private double length;
  5.     private double width;
  6.     private double height;
  7.  
  8.     public Box(double length, double width, double height) {
  9.         super();
  10.         this.length = length;
  11.         this.width = width;
  12.         this.height = height;
  13.     }
  14.  
  15.     public double getLength() {
  16.         return length;
  17.     }
  18.  
  19.     public void setLength(double length) {
  20.         this.length = length;
  21.     }
  22.  
  23.     public double getWidth() {
  24.         return width;
  25.     }
  26.  
  27.     public void setWidth(double width) {
  28.         this.width = width;
  29.     }
  30.  
  31.     public double getHeight() {
  32.         return height;
  33.     }
  34.  
  35.     public void setHeight(double height) {
  36.         this.height = height;
  37.     }
  38.  
  39.     public double getVolume() {
  40.         return length * width * height;
  41.     }
  42.  
  43.     @Override
  44.     public String toString() {
  45.         return "Box [length=" + length + ", width=" + width + ", height=" + height + "]";
  46.     }
  47.  
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement