Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Practice;
- public class Box {
- double height;
- double width;
- double length;
- // constructor - no return type
- Box( double l, double w, double h ) {
- height = h;
- width = w;
- length = l;
- }
- // Constructor Overloading
- Box() {
- height = -1;
- width = -1;
- length = -1;
- }
- Box( double val ) {
- height = width = length = val;
- }
- void setValues( double l, double w, double h ) {
- length = l;
- width = w;
- height = h;
- }
- double getVolume() {
- return height * width * length;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement