Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DATE
- {
- private int year;
- private int month;
- private int day;
- public DATE(int year, int month, int day)
- {
- this.year = year;
- this.month = month;
- this.day = day;
- }
- public DATE(DATE other)
- {
- this.year = other.year;
- this.month = other.month;
- this.day = other.day;
- }
- ~DATE()
- {
- }
- public int GetYear()
- {
- return year;
- }
- public void SetYear(int year)
- {
- this.year = year;
- }
- public int GetMonth()
- {
- return month;
- }
- public void SetMonth(int month)
- {
- this.month = month;
- }
- public int GetDay()
- {
- return day;
- }
- public void SetDay(int day)
- {
- this.day = day;
- }
- public void Load(int year, int month, int day)
- {
- this.year = year;
- this.month = month;
- this.day = day;
- }
- // Overload assignment operator
- public static DATE operator =(DATE a, DATE b)
- {
- a.year = b.year;
- a.month = b.month;
- a.day = b.day;
- return a;
- }
- public static void Input(DATE d)
- {
- Console.WriteLine("Enter year:");
- d.year = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Enter month:");
- d.month = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Enter day:");
- d.day = Convert.ToInt32(Console.ReadLine());
- }
- public static void Output(DATE d)
- {
- Console.WriteLine("{0}/{1}/{2}", d.month, d.day, d.year);
- }
- }
- public class BOOK : DATE
- {
- private string authorName;
- private string title;
- private string publisher;
- private int numPages;
- // Constructor
- public BOOK(string authorName, string title, string publisher, int numPages, int year, int month, int day) : base(year, month, day)
- {
- this.authorName = authorName;
- this.title = title;
- this.publisher = publisher;
- this.numPages = numPages;
- }
- /
- public BOOK(BOOK other) : base(other)
- {
- this.authorName = other.authorName;
- this.title = other.title;
- this.publisher = other.publisher;
- this.numPages = other.numPages;
- }
- ~BOOK()
- {
- }
- public string GetAuthorName()
- {
- return authorName;
- }
- public void SetAuthorName(string authorName)
- {
- this.authorName = authorName;
- }
- public string GetTitle()
- {
- return title;
- }
- public void SetTitle(string title)
- {
- this.title = title;
- }
- public string GetPublisher()
- {
- return publisher;
- }
- public void SetPublisher(string publisher)
- {
- this.publisher = publisher;
- }
- public int GetNumPages()
- {
- return numPages;
- }
- public void SetNumPages(int numPages)
- {
- this.numPages = numPages;
- }
- public virtual string ReadInfo()
- {
- return GetYear().ToString();
- }
- public class LIBRARY
- {
- private BOOK[] books;
- public LIBRARY(int numBooks)
- {
- books = new BOOK[numBooks];
- }
- ~LIBRARY()
- {
- }
- // Indexer to access books array
- public BOOK this[int index]
- {
- get { return books[index]; }
- set { books[index] = value; }
- }
- public class Tertiary
- {
- private BOOK[] books;
- private int currentIndex;
- public Tertiary(BOOK[] books)
- {
- this.books = books;
- currentIndex = 0;
- }
- public BOOK GetCurrentBook()
- {
- return books[currentIndex];
- }
- public void MoveNext()
- {
- currentIndex++;
- }
- public void Reset()
- {
- currentIndex = 0;
- }
- public bool HasNext()
- {
- return currentIndex < books.Length;
- }
- }
- public class Iterator : IEnumerable<BOOK>
- {
- private BOOK[] books;
- // Constructor
- public Iterator(BOOK[] books)
- {
- this.books = books;
- }
- public IEnumerator<BOOK> GetEnumerator()
- {
- for (int i = 0; i < books.Length; i++)
- {
- yield return books[i];
- }
- }
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment