-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBox.java
More file actions
106 lines (79 loc) · 1.79 KB
/
Box.java
File metadata and controls
106 lines (79 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//Sakib Ahmed Shishir - 2312546642
package com.mycompany.box;
public class Box {
private double width;
private double height;
private double depth;
public Box() // constructor
{
width = 1.0;
height = 1.0;
depth = 1.0;
}
public Box(double len)
{
width = len;
height = len;
depth = len;
}
public Box(double width, double height, double depth)
{
this.width = width; //using this referrence
this.height = height;
this.depth = depth;
}
public Box(Box box)
{
width = box.width;
height = box.height;
depth = box.depth;
}
//methods
// Getters
public double getWidth()
{
return width;
}
public double getHeight()
{
return height;
}
public double getDepth()
{
return depth;
}
//Setters
public void setWidth(double width)
{
this.width = width;
}
public void setHeight(double height)
{
this.height = height;
}
public void setDepth(double depth)
{
this.depth = depth;
}
public void setDim(double width, double height, double depth) //Dim = Dimesions
{
this.width = width;
this.height = height;
this.depth = depth;
}
// Equality Check
public boolean equalTo(Box o)
{
return this.width == o.width && this.height == o.height && this.depth == o.depth;
}
// Volume Calculation
public double volume()
{
return width * height * depth;
}
@Override //handy tool
public String toString()
{
return "Box (Width=" + width + ", Height=" + height + ", Depth=" + depth + ")";
}
}