-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSolution.java
More file actions
102 lines (84 loc) · 3.43 KB
/
Solution.java
File metadata and controls
102 lines (84 loc) · 3.43 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
package com.javarush.task.task15.task1507;
//Now I have told you before it happens so that, when it happens, you may believe (John 14:29)
/*
ООП - Перегрузка
*/
public class Solution {
public static void main(String[] args) {
printMatrix(2, 3, "8");
}
public static void printMatrix(int m, int n, double value) {
System.out.println("Заполняем объектами double");
printMatrix(m, n, (Object) value);
}
public static void printMatrix(int m, int n, float value) {
System.out.println("Заполняем объектами float");
printMatrix(m, n, (Object) value);
}
public static void printMatrix(int m, int n, short value) {
System.out.println("Заполняем объектами short");
printMatrix(m, n, (Object) value);
}
public static void printMatrix(int m, int n, byte value) {
System.out.println("Заполняем объектами byte");
printMatrix(m, n, (Object) value);
}
public static void printMatrix(int m, int n, int value) {
System.out.println("Заполняем объектами int");
printMatrix(m, n, (Object) value);
}
public static void printMatrix(int m, int n, Integer value) {
System.out.println("Заполняем объектами Integer");
printMatrix(m, n, (Object) value);
}
public static void printMatrix(int m, int n, char value) {
System.out.println("Заполняем объектами char");
printMatrix(m, n, (Object) value);
}
public static void printMatrix(int m, int n, long value) {
System.out.println("Заполняем объектами long");
printMatrix(m, n, (Object) value);
}
public static void printMatrix(int m, int n, String value) {
System.out.println("Заполняем объектами String");
printMatrix(m, n, (Object) value);
}
public static void printMatrix(int m, int n, Object value) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print(value);
}
System.out.println();
}
}
}
/*
ООП - Перегрузка
Перегрузите метод printMatrix 8 различными способами. В итоге должно получиться 10 различных методов printMatrix.
Требования:
1. В классе Solution должны быть реализованы 10 методов printMatrix с различными аргументами.
2. Класс Solution должен быть public.
3. Все методы класса Solution должны быть статическими.
4. Все методы класса Solution должны быть публичными.
package com.javarush.task.task15.task1507;
*
ООП - Перегрузка
*
public class Solution {
public static void main(String[] args) {
printMatrix(2, 3, "8");
}
public static void printMatrix(int m, int n, String value) {
System.out.println("Заполняем объектами String");
printMatrix(m, n, (Object) value);
}
public static void printMatrix(int m, int n, Object value) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
System.out.print(value);
}
System.out.println();
}
}
}
*/