Skip to content

Commit 699b030

Browse files
FabrizioFabrizio
authored andcommitted
updated
1 parent 42687bb commit 699b030

File tree

13 files changed

+158
-5
lines changed

13 files changed

+158
-5
lines changed

Command/src/client/Client.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
public class Client {
88

9-
public static void main(String[] args) {
9+
public static void main(String[] args) throws InterruptedException {
1010
Invoker invoker = new Invoker(new Receiver());
1111
invoker.setCommand(TypeCommand.OPEN);
1212
invoker.execute();
13+
Thread.sleep(1500);
1314
invoker.setCommand(TypeCommand.EXIT);
1415
invoker.execute();
1516
}

Command/src/command/ExitCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public ExitCommand(Receiver receiver) {
1212

1313
@Override
1414
public void execute() {
15-
receiver.close();
15+
receiver.exit();
1616
}
1717

1818
}

Command/src/receiver/Receiver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
public class Receiver {
44

55
public void open() {
6-
System.out.println("open.");
6+
System.out.println("open");
77
}
88

9-
public void close() {
10-
System.out.println("close.");
9+
public void exit() {
10+
System.out.println("exit");
1111
}
1212
}

Strategy/.classpath

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
5+
<classpathentry kind="output" path="bin"/>
6+
</classpath>

Strategy/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

Strategy/.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Strategy</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8

Strategy/src/ContextVisit.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
public class ContextVisit<T> {
3+
4+
private Visit<T> visit;
5+
6+
private Node<T> root;
7+
8+
public ContextVisit(Node<T> root) {
9+
this.root = root;
10+
}
11+
12+
public void setRoot(Node<T> root) {
13+
this.root = root;
14+
}
15+
16+
public void setVisit(Visit<T> visit) {
17+
this.visit = visit;
18+
}
19+
20+
public void visit() {
21+
visit.visit(root);
22+
}
23+
}

Strategy/src/DeepVisit.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
public class DeepVisit<T> implements Visit<T> {
3+
4+
@Override
5+
public void visit(Node<T> root) {
6+
System.out.print(root);
7+
for(Node<T> node: root.getChildren())
8+
visit(node);
9+
}
10+
11+
}

Strategy/src/LevelVisit.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import java.util.ArrayList;
2+
3+
public class LevelVisit<T> implements Visit<T> {
4+
5+
@Override
6+
public void visit(Node<T> root) {
7+
ArrayList<Node<T>> queue = new ArrayList<Node<T>>();
8+
queue.add(root);
9+
while(!queue.isEmpty()) {
10+
System.out.print(queue.get(0));
11+
queue.addAll(queue.get(0).getChildren());
12+
queue.remove(0);
13+
}
14+
}
15+
16+
}

0 commit comments

Comments
 (0)