Formatted all files to the same standard

This commit is contained in:
matthew
2014-10-08 13:42:12 +01:00
parent 53a2a8b150
commit 3da9ad5469
151 changed files with 952 additions and 870 deletions

View File

@ -1,22 +1,22 @@
package com.iluwatar;
/**
*
*
* Visitor pattern defines mechanism to apply operations (UnitVisitor) on nodes
* (Unit) in hierarchy. New operations can be added without altering the node
* interface.
*
*
*/
public class App {
public static void main(String[] args) {
public static void main(String[] args) {
Commander commander = new Commander(
new Sergeant(new Soldier(), new Soldier(), new Soldier()),
new Sergeant(new Soldier(), new Soldier(), new Soldier()));
commander.accept(new SoldierVisitor());
commander.accept(new SergeantVisitor());
commander.accept(new CommanderVisitor());
Commander commander = new Commander(new Sergeant(new Soldier(),
new Soldier(), new Soldier()), new Sergeant(new Soldier(),
new Soldier(), new Soldier()));
commander.accept(new SoldierVisitor());
commander.accept(new SergeantVisitor());
commander.accept(new CommanderVisitor());
}
}
}

View File

@ -2,7 +2,7 @@ package com.iluwatar;
public class Commander extends Unit {
public Commander(Unit ... children) {
public Commander(Unit... children) {
super(children);
}
@ -11,7 +11,7 @@ public class Commander extends Unit {
visitor.visitCommander(this);
super.accept(visitor);
}
@Override
public String toString() {
return "commander";

View File

@ -2,7 +2,7 @@ package com.iluwatar;
public class Sergeant extends Unit {
public Sergeant(Unit ... children) {
public Sergeant(Unit... children) {
super(children);
}
@ -11,7 +11,7 @@ public class Sergeant extends Unit {
visitor.visitSergeant(this);
super.accept(visitor);
}
@Override
public String toString() {
return "sergeant";

View File

@ -2,7 +2,7 @@ package com.iluwatar;
public class Soldier extends Unit {
public Soldier(Unit ... children) {
public Soldier(Unit... children) {
super(children);
}
@ -11,7 +11,7 @@ public class Soldier extends Unit {
visitor.visitSoldier(this);
super.accept(visitor);
}
@Override
public String toString() {
return "soldier";

View File

@ -1,7 +1,7 @@
package com.iluwatar;
/**
*
*
* Interface for the nodes in hierarchy.
*
*/
@ -9,12 +9,12 @@ public abstract class Unit {
private Unit[] children;
public Unit(Unit ... children) {
public Unit(Unit... children) {
this.children = children;
}
public void accept(UnitVisitor visitor) {
for (Unit child: children) {
for (Unit child : children) {
child.accept(visitor);
}
}

View File

@ -3,12 +3,14 @@ package com.iluwatar;
/**
*
* Visitor interface.
*
*
*/
public interface UnitVisitor {
void visitSoldier(Soldier soldier);
void visitSergeant(Sergeant sergeant);
void visitCommander(Commander commander);
}