-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStringAnimator.java
62 lines (49 loc) · 906 Bytes
/
StringAnimator.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
package Count;
class Shared{
public synchronized String PrintWc(char c,String p) {
String s=p+c;
if (Character.isUpperCase(c)) {
for(char i='A';i<=c;i++) {
try {
Thread.sleep(300);
}catch(Exception e) {
}
System.out.println(p+i);
}
}
if (Character.isLowerCase(c)) {
for(char i='a';i<=c;i++) {
try {
Thread.sleep(300);
}catch(Exception e) {
}
System.out.println(p+i);
}
}
return s;
}
}
class Words{
private Shared s;
Words(Shared s){
this.s=s;
}
void PrintS() {
String p="",Sentence="Hello World";
for(char i: Sentence.toCharArray()) {
if(i=='c') {
p=p+i;
}else {
p=s.PrintWc(i,p);
}
}
}
}
public class StringAnimator {
public static void main(String[] args) {
Shared s=new Shared();
Words w=new Words(s);
Thread t=new Thread(()->w.PrintS());
t.start();
}
}