-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstr1
More file actions
48 lines (36 loc) · 904 Bytes
/
Copy pathconstr1
File metadata and controls
48 lines (36 loc) · 904 Bytes
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
// Простой конструктор.
class Box {
int width; // ширина коробки
int height; // высота коробки
int depth; // глубина коробки
// Конструктор
Box() {
width = 10;
height = 10;
depth = 10;
}
// вычисляем объём коробки
int getVolume() {
return width * height * depth;
}
}
class constr {
int a;
int b;
// int c;
// Ниже конструктор
constr (int A, int B ) {
a=A;
b=B;
//c=a/b;
}
}
public class construct{
public static void main(String args[]) {
constr t1 = new constr(10, 8);
//constr t2 = new constr();
System.out.println(t1.a / t1.b);
Box catBox = new Box();
System.out.println("Объём коробки: " + catBox.getVolume());
}
}