-
Notifications
You must be signed in to change notification settings - Fork 0
/
DI2.java
37 lines (31 loc) · 908 Bytes
/
DI2.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
import java.nio.charset.StandardCharsets;
abstract class SpellChecker {
public abstract Boolean check(String sc);
}
class TextEditor {
private SpellChecker sc;
public TextEditor(SpellChecker sc) {
this.sc = sc;
}
public void run() {
sc.check("auis");
sc.check("AUIS");
sc.check("omer");
}
}
class WinSpecllChecker extends SpellChecker {
public Boolean check(String sc) {
if (sc.getBytes().equals(sc.getBytes(StandardCharsets.UTF_8))) {
System.out.println("word matched: " + " " + sc);
return true;
} else System.out.println("not matched: " + " " + sc);
return false;
}
}
public class DI2 {
public static void main(String[] args) {
SpellChecker sc = new WinSpecllChecker();
TextEditor t = new TextEditor(sc);
t.run();
}
}