Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. class Informacja : ICloneable, IComparable, IEnumerable
  2. {
  3. public int Rozmiar
  4. {
  5. get
  6. {
  7. return _letters.Count();
  8. }
  9. private set
  10. {
  11. }
  12. }
  13.  
  14. private char[] _letters;
  15.  
  16. public char this[int indeks]// indeksator
  17. {
  18. get
  19. {
  20. return this._letters[indeks];
  21. }
  22.  
  23. set
  24. {
  25. this._letters[indeks] = value;
  26. }
  27. }
  28.  
  29. public Informacja()//pusty konstruktor
  30. {
  31. }
  32.  
  33. public Informacja(char[] collection)//konstruktor z listą
  34. {
  35. this._letters = (char[])collection.Clone();
  36. }
  37.  
  38. public IEnumerator GetEnumerator()//not ready
  39. {
  40. //return (IEnumerator)this;
  41. }
  42.  
  43. public object Clone()//not ready
  44. {
  45. return new Informacja(this._letters);
  46. }
  47.  
  48. public int CompareTo(object ob)//porównanie wg długosci list
  49. {
  50. Informacja temp = (Informacja)ob;
  51. if (this.Rozmiar > temp.Rozmiar)
  52. return 1;
  53. else
  54. if (this.Rozmiar == temp.Rozmiar)
  55. return 0;
  56. else return -1;
  57. }
  58.  
  59. public void Usun(int indeks)//usuwa jeden element tablicy
  60. {
  61. char[] tmp = new char[this.Rozmiar - 1];
  62. for (int i = 0; i < Rozmiar-1; i++)
  63. {
  64. if (i<indeks)
  65. {
  66. tmp[i] = this[i];
  67. }
  68. else
  69. {
  70. if (i=indeks)
  71. {
  72. i--;
  73. }
  74. else
  75. {
  76. tmp[i] = this[i];
  77. }
  78. }
  79. }
  80. this._letters = tmp;
  81. }
  82.  
  83. public char[] NaDuze()//kazdy znak zmieniony na duze
  84. {
  85. char[] tmp = new char[this.Rozmiar];
  86. for (int i = 0; i < this.Rozmiar; i++)
  87. {
  88. tmp[i] = Char.ToUpper(this[i]);
  89. }
  90. return tmp;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement