JAVA/code by me
Heart - Thread, for
Y_____527
2021. 1. 30. 16:52
<Heart.java>
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
|
package quiz1.thread;
public class Heart implements Runnable {
@Override
public void run() {
try {
while (true) {
int i;
System.out.println();
for (i = 4; i < 10; i += 2) {
MakeHeart1(10 - i);
MakeHeart2(i * 2);
MakeHeart1((10 - i) * 2);
MakeHeart2(i * 2);
System.out.println();
}
for (i = 20; i >= 0; i -= 2) {
MakeHeart1(20 - i);
MakeHeart2(i * 2);
System.out.println();
}
Thread.sleep(500);
for (i = 4; i < 10; i += 2) {
MakeHeart1(10 - i);
MakeHeart3(i * 2);
MakeHeart1((10 - i) * 2);
MakeHeart3(i * 2);
System.out.println();
}
for (i = 20; i >= 0; i -= 2) {
MakeHeart1(20 - i);
MakeHeart3(i * 2);
System.out.println();
}
Thread.sleep(500);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public void MakeHeart1(int a) {
int j;
for (j = 0; j < a; j++) {
System.out.print(" ");
}
}
public void MakeHeart2(int a) {
int j;
for (j = 0; j <= a; j++) {
System.out.print("♡");
}
}
public void MakeHeart3(int a) {
int j;
for (j = 0; j <= a; j++) {
System.out.print("♥");
}
}
}
|
cs |
<HeartMain.java>
1
2
3
4
5
6
7
8
9
10
11
|
package quiz1.thread;
public class HeartMain {
public static void main(String[] args) {
new Thread(new Heart()).start();
}
}
|
cs |