Advertisement
Quat

Untitled

Jun 25th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.85 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Globalization;
  4. using System.Collections.Generic;
  5.  
  6. namespace teest
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.  
  13.             List< Books> library = new List<Books>();
  14.            SortedDictionary<string, DateTime> requestedInfo = new SortedDictionary<string, DateTime>();
  15.             int caunt =int.Parse(Console.ReadLine()); // caunt of the books
  16.             for (int i = 0; i < caunt; i++)
  17.             {
  18.  
  19.                 string[] token = Console.ReadLine().Split(' ').ToArray();
  20.                 string author = token[2];
  21.                 Books book = new Books(                                                                        
  22.                 token[0],                                                                           // title        
  23.                 token[1],                                                                           // author                          
  24.                 token[2],                                                                           // publisher                      
  25.                 DateTime.ParseExact(token[3], "dd.MM.yyyy", CultureInfo.InvariantCulture),          // reliseDate                                    
  26.                 token[4],                                                                           // isbn    
  27.                 double.Parse(token[5]));                                                            // price        
  28.                 library.Add(book);
  29.  
  30.             }
  31.             string tokenData = Console.ReadLine();
  32.             DateTime minimumData = DateTime.ParseExact(tokenData,"dd.MM.yyyy", CultureInfo.InvariantCulture);
  33.             foreach (var author in library)
  34.             {
  35.  
  36.                 requestedInfo.Add(author.title, author.reliseDate);
  37.            
  38.  
  39.             }
  40.             foreach (var token in requestedInfo.OrderByDescending(x => x.Key).OrderByDescending(y => y.Value))
  41.             {
  42.                 if (minimumData >= token.Value)
  43.                 {
  44.                     Console.WriteLine($" {token.Key} -> {token.Value} ");
  45.                 }
  46.                
  47.             }
  48.            
  49.         }
  50.     }
  51.     public class Books
  52.     {
  53.         public string title { get; set; }
  54.         public string author { get; set; }
  55.         public string publisher { get; set; }
  56.         public DateTime reliseDate { get; set; }
  57.         public string isbn { get; set; }
  58.         public double price { get; set; }
  59.  
  60.         public Books(string title, string author, string publisher, DateTime MyProperty, string isbn, double price)
  61.         {
  62.             this.title = title;
  63.             this.author = author;
  64.             this.publisher = publisher;
  65.             this.reliseDate = reliseDate;
  66.             this.isbn = isbn;
  67.             this.price = price;
  68.         }
  69.  
  70.     }
  71.    
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement