Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 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 _06.Book_Library_Modification
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             //{title} {author} {publisher} {release date} {ISBN} {price}.
  15.             long numberOfBooks = long.Parse(Console.ReadLine());
  16.             Dictionary<string, Book> books = new Dictionary<string, Book>();
  17.  
  18.             for (long i = 0; i < numberOfBooks; i++)
  19.             {
  20.                 var input = Console.ReadLine().Split(' ');
  21.                 if (!books.ContainsKey(input[1]))
  22.                     books.Add(input[0], new Book() { ReleaseDate = DateTime.ParseExact(input[3], "dd.MM.yyyy" , CultureInfo.InvariantCulture) });
  23.             }
  24.             DateTime newDate = DateTime.ParseExact(Console.ReadLine() , "dd.MM.yyyy" ,CultureInfo.InvariantCulture);
  25.             foreach (var book in books.OrderBy(x => x.Value.ReleaseDate).ThenBy(x => x.Key).Where(x => x.Value.ReleaseDate >= newDate))
  26.             {
  27.                 Console.WriteLine("{0} -> {1:dd.MM.yyyy}" , book.Key ,book.Value.ReleaseDate);
  28.             }
  29.         }
  30.     }
  31.     public class Library
  32.     {
  33.         public string Name { get; set; }
  34.         public List<Book> Books { get; set; }
  35.  
  36.     }
  37.     public class Book
  38.     {
  39.         public string Title { get; set; }
  40.         public string Author { get; set; }
  41.         public string Publisher { get; set; }
  42.         public DateTime ReleaseDate { get; set; }
  43.         public long ISBN { get; set; }
  44.         public decimal Price { get; set; }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement