diff --git a/ws2012/P2P/uebungen/4/src/peer/Node.java b/ws2012/P2P/uebungen/4/src/peer/Node.java index 93465992..66c74a3b 100644 --- a/ws2012/P2P/uebungen/4/src/peer/Node.java +++ b/ws2012/P2P/uebungen/4/src/peer/Node.java @@ -6,19 +6,15 @@ import java.util.List; public class Node { -<<<<<<< HEAD + // node id must be unique! id = IP of peer ?!? // -> Should be unique if we don't consider peers behind a NAT. private int id; - private List neighbours; -======= - private int id; // node id must be unique! id = IP of peer ?!? - //-> Should be unique if we don't consider peers behind a NAT. private String name; private List neighbours = new ArrayList(); ->>>>>>> some improvements + public Node(int id, String name){ this.id = id; @@ -76,7 +72,7 @@ public class Node { return (this.neighbours.size() > 0); } -<<<<<<< HEAD + /** * checks if actual node has neighbour with given id * @@ -89,7 +85,10 @@ public class Node { if(tmp.id == id){ return true; } -======= + } + return false; + } + public int getId(){ return this.id; } @@ -104,18 +103,11 @@ public class Node { System.out.print("Name: " + this.name + ", Neighbours: "); for(int i = 0; i < this.neighbours.size(); i++){ System.out.print(this.neighbours.get(i).name + ", "); ->>>>>>> some improvements + } System.out.println(); } -<<<<<<< HEAD -} -======= - - - - - + } ->>>>>>> some improvements + diff --git a/ws2012/P2P/uebungen/4/src/peer/Peer.java b/ws2012/P2P/uebungen/4/src/peer/Peer.java index 0812cc71..b21ddf5a 100644 --- a/ws2012/P2P/uebungen/4/src/peer/Peer.java +++ b/ws2012/P2P/uebungen/4/src/peer/Peer.java @@ -7,23 +7,7 @@ import java.util.Random; public class Peer { private Node node; -<<<<<<< HEAD - /** - * Create another peer, mutually link creator and spawn. - */ - public void spawn() { - - } - - /** - * Circularly link all neighbours, remove itself form all neighbours and - * exit. - */ - public void leave() { - -======= - public Peer(String name){ this.node = new Node(new Random().nextInt(), name); @@ -34,7 +18,9 @@ public class Peer { } - //create another peer, mutually link creator and spawn + /** + * Create another peer, mutually link creator and spawn. + */ public void spawn(String name){ //create a new node Node spawnNode = new Node(new Random().nextInt(), name); @@ -46,7 +32,10 @@ public class Peer { } - //circularly link all neighbours, remove itself form all neighbours and exit + /** + * Circularly link all neighbours, remove itself form all neighbours and + * exit. + */ public void leave(){ List neighbours = this.node.getNeighbours(); @@ -56,7 +45,6 @@ public class Peer { //remove itself neighbours.get(i).removeNeighbour(this.node); } ->>>>>>> some improvements }