/
Test.java
61 lines (48 loc) · 1.31 KB
/
Test.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
package frodo;
public class Test {
public static void main(String[] args) {
new Test().run();
}
public void run() {
System.out.println(someMethod(new RealFile("Hello")));
System.out.println(someMethod(new RealFile("World")));
for (int i = 0; i < 10; i++) {
if (i % 3 == 0) {
someMethod(new RealFile("" + i));
} else if (i % 3 == 1) {
anotherMethod(0, new RealFile(" " + i));
} else {
aThirdMethod(0, new VirtualFile[] { new RealFile(" " + i), new RealFile(" " + i), new RealFile(" " + i) });
}
}
}
public String someMethod(VirtualFile file) {
return "Hello " + file.getPath();
}
public String anotherMethod(int random, VirtualFile file) {
return "Goodbye " + file.getPath();
}
public String aThirdMethod(int random, VirtualFile[] file) {
return "The third method ";
}
private abstract static class VirtualFile {
public abstract String getPath();
}
private static class RealFile extends VirtualFile {
private String path;
RealFile(String path) {
this.path = path;
}
@Override
public String getPath() {
return path;
}
@Override
public String toString() {
return getPath();
}
}
public static String printThingy(VirtualFile f) {
return "A thingy was called";
}
}