Guest User

Untitled

a guest
Jan 19th, 2018
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. /**
  2. * Node class for holding the value and position of an element.
  3. * @author Charlie Davis (CLD0023@auburn.edu)
  4. * @version 2011-04-04
  5. */
  6. public class Node {
  7. private int position;
  8. private int value;
  9. /**
  10. *Empty constructor.
  11. */
  12. public Node() {
  13.  
  14. }
  15. /**
  16. *Takes in a Node and basically copies the value and position.
  17. *@param n Node to copy values from.
  18. */
  19. public Node(Node n)
  20. {
  21. setValue(n.getValue());
  22. setPosition(n.getPosition());
  23. }
  24. /**
  25. *Constructor that takes in value and position int's and sets them.
  26. *@param value to be set.
  27. *@param position to be set.
  28. */
  29. public Node(int v, int p) {
  30. this.setValue(v);
  31. this.setPosition(p);
  32. }
  33. /**
  34. *Returns the value this Node contains.
  35. *@return value the node contains.
  36. */
  37.  
  38. public int getValue() {
  39. return value;
  40. }
  41. /**
  42. *Returns the position of this Node.
  43. *@return int position this Node holds.
  44. */
  45. public int getPosition() {
  46. return position;
  47. }
  48. /**
  49. *Sets the value of this node to the parameter
  50. *@param v value to be set.
  51. */
  52. public void setValue(int v) {
  53. this.value = value;
  54. }
  55. /**
  56. *Sets the position of this node to the parameter.
  57. *@param p position to be set.
  58. */
  59. public void setPosition(int p) {
  60. this.position = position;
  61. }
  62. }
Add Comment
Please, Sign In to add comment