-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBox.java
More file actions
73 lines (59 loc) · 1.71 KB
/
Copy pathBox.java
File metadata and controls
73 lines (59 loc) · 1.71 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
package classesIntro;
/**
* Created by WERT on 13.01.2017.
*/
class Box {
double width;
double height;
double depth;
String label = "Box";
// конструктор принмающий три параметра
Box(double w, double h, double d) {
width = w;
height = h;
depth = d;
}
// конструктор без параметров (по умолчанию)
Box() {
}
// конструктор принимающий один параметр
Box(double size) {
width = height = depth = size;
}
// метод вывода объема на консоль
void printVolume() {
System.out.print(width * height * depth);
}
// метод вывода размеров Box на консоль
void printSizes() {
System.out.println("width = " + width);
System.out.println("height = " + height);
System.out.println("depth = " + depth);
}
// метод получения объема, возвращает double
double getVolume() {
return width * height * depth;
}
// задаем один и тот же размер
void setSameSize(double size) {
width = height = depth = size;
}
// задаем все размеры
void setSizes(double w, double h, double d) {
width = w;
height = h;
depth = d;
}
// перегруженный метод setData
void setData(double size) {
width = height = depth = size;
}
void setData(double w, double h, double d) {
width = w;
height = h;
depth = d;
}
void setData(String boxLabel) {
label = boxLabel;
}
}