Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. # data handler
  2.  
  3. # logic
  4. class Location:
  5. def __init__(self, name, units):
  6. self.name = name
  7. self.units = units
  8.  
  9. def update(self):
  10. # slome logic
  11. self.units.append("unit_after_update")
  12.  
  13. # visualization handler
  14. class Screen:
  15. def __init__(self, name, location):
  16. self.name = name
  17. self.location = location
  18.  
  19. def update(self):
  20. print("updating")
  21. self.location.update()
  22.  
  23. def __repr__(self):
  24. return f"{self.name} units:{self.location.units}"
  25.  
  26.  
  27. loc = Location("location_1", ["unit_1",])
  28. scr = Screen("temp", loc)
  29. print(scr)
  30. scr.update()
  31. scr.update()
  32. print(scr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement