Advertisement
martinvalchev

Book_Library_Modification

Feb 18th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Book_Library_Modification
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int n = int.Parse(Console.ReadLine());
  15.             List<Book> myBook = new List<Book>();
  16.             for (int i = 0; i < n; i++)
  17.             {
  18.                 string[] input = Console.ReadLine().Split(' ').ToArray();
  19.                 Book book = new Book();
  20.                 book.Title = input[0];
  21.                 book.Author = input[1];
  22.                 book.Publisher = input[2];
  23.                 book.ReleaseDay = DateTime.ParseExact(input[3], "dd.MM.yyyy", CultureInfo.InvariantCulture);
  24.                 book.ISBN = input[4];
  25.                 book.Price = double.Parse(input[5]);
  26.  
  27.                 myBook.Add(book);
  28.  
  29.             }
  30.  
  31.             DateTime finalDate = DateTime.ParseExact(Console.ReadLine(), "dd.MM.yyyy", CultureInfo.InvariantCulture);
  32.  
  33.             Library myLibrary = new Library();
  34.             myLibrary.Books = myBook;
  35.  
  36.             foreach (var book in myLibrary.Books.Where(x =>x.ReleaseDay>finalDate).OrderBy(x=>x.ReleaseDay).ThenBy(x=>x.Title))
  37.             {
  38.                 Console.WriteLine($"{book.Title} -> {book.ReleaseDay.ToString("dd.MM.yyyy")}");
  39.             }
  40.  
  41.  
  42.         }
  43.     }
  44.  
  45.     class Book
  46.     {
  47.         public string Title { get; set; }
  48.         public string Author { get; set; }
  49.         public string Publisher { get; set; }
  50.         public DateTime ReleaseDay { get; set; }
  51.         public string ISBN { get; set; }
  52.         public double Price { get; set; }
  53.     }
  54.  
  55.     class Library
  56.     {
  57.         public List<Book> Books { get; set; }
  58.         public string Name { get; set; }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement