added 'Shell' and 'ShellControl' and editet the two visitors 'Visitor' and 'VoidVisitor'

This commit is contained in:
Benjamin Feyer
2024-10-10 22:23:55 +02:00
parent dffb5b4d63
commit 30a735bd6e
4 changed files with 76 additions and 0 deletions

View File

@@ -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;
}
}

View File

@@ -28,4 +28,6 @@ public interface Visitor<T> {
* @return the result of visiting the Battleship element
*/
T visit(Battleship ship);
T visit(Shell shell);
}

View File

@@ -25,4 +25,6 @@ public interface VoidVisitor {
* @param ship the Battleship element to visit
*/
void visit(Battleship ship);
void visit(Shell shell);
}