Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.IO;
- namespace program
- {
- class Program
- {
- static public Publish[] Input()
- {
- using (StreamReader fileIn = new StreamReader("base.txt"))
- {
- int n = int.Parse(fileIn.ReadLine());
- Publish[] ar = new Publish[n];
- for (int i = 0; i < n; i++)
- {
- string[] text = fileIn.ReadLine().Split(' ');
- if (text[0] == "Book")
- ar[i] = new Book(text[1], text[2], Int32.Parse(text[3]), text[4]);
- else if (text[0] == "Article")
- ar[i] = new Article(text[1], text[2], Int32.Parse(text[3]), text[4], Int32.Parse(text[5]));
- else if (text[0] == "ElecResource")
- ar[i] = new ElecResource(text[1], text[2], text[3], text[4]);
- }
- return ar;
- }
- }
- public static void Main(string[] args)
- {
- Publish[] arr = Input();
- Console.WriteLine("Все издания: \n");
- for(int i = 0; i < arr.Length; i++){
- arr[i].displayInfo();
- Console.WriteLine();
- }
- Array.Sort(arr);
- Console.WriteLine("Все издания после сортировки: \n");
- for(int i = 0; i < arr.Length; i++){
- arr[i].displayInfo();
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement