Also ein Kommilitone von mir hat mich um Hilfe gebeten, ihm zu helfen ein "Movement System" zu coden. Dieses ist im Grunde eine 8-fach double Linked List xD Jeder Knoten kennt seine 8 Nachbarn. Jedoch zerbreche ich mir schon seit Stunden meinen Kopf, wie ich eine vernünftige add-Methode implementieren könnte
Ich schicke einfach mal die Code Schnipsel, welche bis jetzt entstanden sind 
Java:
package game;
public class Node<T>{
private int id;
private Node<T> north;
private Node<T> northWest;
private Node<T> west;
private Node<T> southWest;
private Node<T> south;
private Node<T> southEast;
private Node<T> east;
private Node<T> northEast;
public Node(Node<T> n, Node<T> nw, Node<T> w, Node<T> sw, Node<T> s, Node<T> so, Node<T> o, Node<T> no, int id) {
this.north = n;
this.northWest = nw;
this.west = w;
this.southWest = sw;
this.south = s;
this.southEast = so;
this.south = o;
this.northEast = no;
this.id = id;
}
public Node<T> getNorth(){
return north;
}
public void setNoth(Node<T> north) {
this.north = north;
}
public Node<T> getNorthWest(){
return northWest;
}
public void setNorthWest(Node<T> northWest) {
this.northWest = northWest;
}
public Node<T> getWest(){
return west;
}
public void setWest(Node<T> west) {
this.west = west;
}
public Node<T> getSouthWest(){
return southWest;
}
public void setSouthWest(Node<T> southWest) {
this.southWest = southWest;
}
public Node<T> getSouth(){
return south;
}
public void setSouth(Node<T> south) {
this.south = south;
}
public Node<T> getSouthEast(){
return southEast;
}
public Node<T> getEast(){
return east;
}
public void setEast(Node<T> east) {
this.east = east;
}
public Node<T> getNorthEast(){
return northEast;
}
}
Java:
package game;
public class LinkedGameList <T> {
private Node<T> front;
private Node<T> newNode;
private static int ID = 1;
public LinkedGameList() {
front = null;
}
public void add() {
if(isEmpty()) {
Node<T> newNode = new Node<T>(null, null, null, null, null, null, null, null, ID);
ID++;
this.front = newNode;
this.newNode = newNode;
}else {
}
}
public boolean isEmpty() {
return front == null;
}
}
Zuletzt bearbeitet: