Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.74 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 P06.BookLibralyModification
  9. {
  10.     class StartUp
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int n=int.Parse(Console.ReadLine());
  15.             List<Book> books=new List<Book>();
  16.             for (int i = 0; i < n; i++)
  17.             {
  18.                 string[] tokens = Console.ReadLine().Split(' ');
  19.                 Book book = new Book
  20.                 {
  21.                     Title = tokens[0],
  22.                     Author = tokens[1],
  23.                     Publisher = tokens[2],
  24.                     ReleaseDate = DateTime.ParseExact(tokens[3], "dd.MM.yyyy", CultureInfo.InvariantCulture),
  25.                     ISBNNumber = tokens[4],
  26.                     Price = double.Parse(tokens[5])
  27.                 };
  28.                 books.Add(book);
  29.             }
  30.             DateTime startDate=DateTime.ParseExact(Console.ReadLine(),"dd.MM.yyyy",
  31.                 CultureInfo.InvariantCulture);
  32.  
  33.             foreach (var book in books.Where(a=>a.ReleaseDate>startDate).OrderBy(a=>a.ReleaseDate).ThenBy(a=>a.Title))
  34.             {
  35.                 Console.WriteLine($"{book.Title} -> {book.ReleaseDate:dd.MM.yyyy}");  
  36.             }
  37.         }
  38.     }
  39.  
  40.     class Library
  41.     {
  42.         public string Name { get; set; }
  43.         public List<Book> Books { get; set; }
  44.     }
  45.  
  46.     class Book
  47.     {
  48.         public string Title { get; set; }
  49.         public string Author { get; set; }
  50.         public string Publisher { get; set; }
  51.         public DateTime ReleaseDate { get; set; }
  52.         public string ISBNNumber { get; set; }
  53.         public double Price { get; set; }
  54.  
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement