Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * written by tariq scott
- */
- public class Box {
- private String label;
- private double length;
- private double width;
- private double height;
- //constructors
- public Box () // my default constructor
- {
- this.label = "none yet";
- this.length = 1.0;
- this.width = 1.0;
- this.height = 1.0;
- }
- public Box (String aLabel, double aLength, double aWidth, double aHeight)
- {
- //TODO fill in mutators
- }
- //accessors
- public String getLabel ()
- {
- return this.label;
- }
- public double getLength ()
- {
- return this.length;
- }
- public double getWidth ()
- {
- return this.width;
- }
- public double getHeight ()
- {
- return this.height;
- }
- public void setLabel (String aLabel)
- {
- this.label = aLabel;
- }
- public void setLengh (double aLength)
- {
- if (aLength >= 0.0)
- {
- this.length = aLength;
- }
- }
- public void setWidth (double aWidth)
- {
- if (aWidth >= 0.0)
- {
- this.width = aWidth;
- }
- }
- public void setHeight (double aHeight)
- {
- if (aHeight >= 0.0)
- {
- this.height = aHeight;
- }
- }
- //other methods
- public String toString()
- {
- return this.label + " " + this.width + " " + this.length + " " + this.height;
- }
- public boolean equals (Box aBox)
- {
- return aBox != null &&
- this.label.equals(aBox.getLabel()) &&
- this.width == aBox.getWidth() &&
- this.height == aBox.getHeight ();
- }
- //volume method
- public double getVolume;
- {
- return this.getWidth()*this.getLength()*this.getHeight();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement