added 'Shell' and 'ShellControl' and editet the two visitors 'Visitor' and 'VoidVisitor'
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package pp.battleship.model;
|
||||
|
||||
public class Shell implements Item {
|
||||
|
||||
private IntPoint target;
|
||||
|
||||
public Shell(IntPoint target){
|
||||
this.target=target;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public <T> T accept(Visitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(VoidVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
public IntPoint getTarget(){
|
||||
return target;
|
||||
}
|
||||
}
|
||||
@@ -28,4 +28,6 @@ public interface Visitor<T> {
|
||||
* @return the result of visiting the Battleship element
|
||||
*/
|
||||
T visit(Battleship ship);
|
||||
|
||||
T visit(Shell shell);
|
||||
}
|
||||
|
||||
@@ -25,4 +25,6 @@ public interface VoidVisitor {
|
||||
* @param ship the Battleship element to visit
|
||||
*/
|
||||
void visit(Battleship ship);
|
||||
|
||||
void visit(Shell shell);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user