Node.java 912 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. public class Node {
  2. // Usually you would use "Generics" at this point to be able
  3. // to hold arbitrary Objects, not only Bikes.
  4. private final Bike element;
  5. private Node next;
  6. /**
  7. * Constructor.
  8. *
  9. * @param element the element you want to add
  10. */
  11. public Node(Bike element) {
  12. this.element = element;
  13. }
  14. /**
  15. * Getter for the content of this node.
  16. *
  17. * @return the element
  18. */
  19. public Bike getElement() {
  20. return element;
  21. }
  22. /**
  23. * @return the next
  24. */
  25. public Node getNext() {
  26. return next;
  27. }
  28. /**
  29. * @param next the next to set
  30. */
  31. public void setNext(Node next) {
  32. this.next = next;
  33. }
  34. /*
  35. * (non-Javadoc)
  36. *
  37. * @see java.lang.Object#toString()
  38. */
  39. @Override
  40. public String toString() {
  41. return "Node[element=" + element + "]";
  42. }
  43. }