Advertisement
Guest User

Untitled

a guest
May 6th, 2015
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace CV5
  9. {
  10. class Slozka : Prvek, IEnumerable
  11. {
  12. private String nazev;
  13.  
  14. public Slozka(String nazev)
  15. {
  16. this.nazev = nazev;
  17. }
  18.  
  19. public override void tisk(int level)
  20. {
  21. for (int i = 0; i < level; i++)
  22. Console.Write(" ");
  23. Console.WriteLine(nazev);
  24. foreach (Prvek prvk in this.prvky)
  25. {
  26. prvk.tisk(level+1);
  27. }
  28. }
  29.  
  30.  
  31.  
  32. public override string getText()
  33. {
  34. return this.nazev;
  35. }
  36.  
  37.  
  38.  
  39.  
  40. public IEnumerator GetEnumerator()
  41. {
  42. return new SlozkaEnumerator(prvky);
  43. }
  44. }
  45.  
  46.  
  47. class SlozkaEnumerator : IEnumerator {
  48.  
  49. private List<Prvek> obsah;
  50. private int index = -1;
  51. public SlozkaEnumerator(List<Prvek> obsah)
  52. {
  53. this.obsah = obsah;
  54. }
  55.  
  56. public object Current
  57. {
  58.  
  59. get { return obsah[index]; }
  60. }
  61.  
  62. public bool MoveNext()
  63. {
  64. index++;
  65. return index < obsah.Count;
  66. }
  67.  
  68. public void Reset()
  69. {
  70. this.index = -1;
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement