Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. public class Visitor
  2. {
  3. public void DoSomething(ITree tree)
  4. {
  5. // treeを使って何かする
  6.  
  7.  
  8. tree.GoToParent(this);
  9. }
  10. }
  11.  
  12. public interface ITree
  13. {
  14. // なんかプロパティもありつつ
  15.  
  16.  
  17. void GoToParent(Visitor visitor);
  18. }
  19.  
  20. public class Node : ITree
  21. {
  22. ITree parent;
  23.  
  24. public void GoToParent(Visitor visitor)
  25. {
  26. visitor.DoSomeothing(parent);
  27. }
  28. }
  29.  
  30. public class Root : ITree
  31. {
  32. public void GoToParent(Visitor visitor)
  33. {
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement