Advertisement
FelipeNeto2

Node (PYTHON)

Dec 13th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. class Node:
  2.   def __init__(self, value, link_node=None):
  3.     self.value = value
  4.     self.link_node = link_node
  5.    
  6.   def set_link_node(self, link_node):
  7.     self.link_node = link_node
  8.    
  9.   def get_link_node(self):
  10.     return self.link_node
  11.  
  12.   def get_value(self):
  13.     return self.value
  14.  
  15. # Add your code below:
  16. yacko = Node("likes to yak")
  17. wacko = Node("has a penchant for hoarding snacks")
  18. dot = Node("enjoys spending time in movie lots")
  19.  
  20. dot.set_link_node(wacko)
  21. yacko.set_link_node(dot)
  22.  
  23. dots_data = yacko.get_link_node().get_value()
  24. wackos_data = dot.get_link_node().get_value()
  25.  
  26. print(dots_data)
  27. print(wackos_data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement