Advertisement
double_trouble

books(IEnumerator)

Jun 19th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication11
  7. {
  8.     class Book
  9.     {
  10.         string author, title;
  11.         decimal price;
  12.         DateTime data;
  13.  
  14.         public Book(string _author, string _title, decimal _price, System.DateTime _data)
  15.         {
  16.             author = _author;
  17.             title = _title;
  18.             price = _price;
  19.             data = _data;
  20.         }
  21.  
  22.         public string Author
  23.         {
  24.             get { return author; }
  25.             set { value = author; }
  26.         }
  27.  
  28.         public string Title
  29.         {
  30.             get { return title; }
  31.             set { value = title; }
  32.         }
  33.  
  34.         public decimal Price
  35.         {
  36.             get { return price; }
  37.             set { value = price; }
  38.         }
  39.  
  40.         public DateTime Data
  41.         {
  42.             get { return data; }
  43.         }
  44.     }
  45.  
  46.     class MyClass
  47.     {
  48.         Book[] M;
  49.         int count;
  50.  
  51.         public MyClass(int cap)
  52.         {
  53.             M = new Book[cap];
  54.         }
  55.  
  56.         public void Add(ConsoleApplication11.Book item)
  57.         {
  58.             M[count] = item;
  59.             count++;
  60.         }
  61.  
  62.         public int Count
  63.         {
  64.             get { return count; }
  65.             set { value = count; }
  66.         }
  67.  
  68.         public MyClass Repeat()
  69.         {
  70.             MyClass nc = new MyClass(0);
  71.             for (int i =0; i < M.Length; i++)
  72.             {
  73.                 {
  74.                     bool f = true;
  75.                     for (int j = 0; j < nc.M.Length; j++)
  76.                         if (nc.M[j] == M[i])
  77.                         {
  78.                             f = false;
  79.                             break;
  80.                         }
  81.                     if (f)
  82.                         nc.Add(M[i]);
  83.                 }
  84.             }
  85.             return nc;
  86.         }
  87.          public System.Collections.IEnumerator GetEnumerator()
  88.         {
  89.             for (int i = 0; i < count; i++)
  90.                 yield return M[i];
  91.         }
  92.     }
  93.  
  94.     class Program
  95.     {
  96.         static void Main(string[] args)
  97.         {
  98.            
  99.         }
  100.     }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement