Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. package hw1;
  2.  
  3. /**
  4. * The itemsLinkedList acts as a linkedlist for all the items.
  5. *
  6. * @author Philip Bei Xu Yong
  7. */
  8. public class itemsLinkedList
  9. {
  10. /**
  11. * This is the constructor for the firstNode.
  12. */
  13. public Node firstNode;
  14.  
  15. /**
  16. * This is the constructor to initialize the firstNode.
  17. * @param info String[] information from text file.
  18. */
  19. itemsLinkedList(String[] info)
  20. {
  21. firstNode = new Node(info);
  22. }
  23.  
  24. /**
  25. * This method looks for the next empty node to add new infomation.
  26. * @param node just references the firstNode.
  27. * @param info String[] information from text file.
  28. */
  29. void add(Node node, String[] info)
  30. {
  31. if(node.next == null)
  32. {
  33. Node nextNode = new Node(info);
  34. node.next = nextNode;
  35. nextNode.prev = node;
  36. }
  37. else
  38. {
  39. add(node.next, info);
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement