Kosty_Fomin

Untitled

Sep 29th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.10 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Linq;
  7. using System.IO;
  8.  
  9. namespace ConsoleApplication6
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             int hour;
  16.             int minute;
  17.  
  18.             do {
  19.                 List<TVShow> shows = new List<TVShow>();
  20.  
  21.                 Console.WriteLine("Input name of tv show");
  22.                 string name =  Console.ReadLine();
  23.                 Console.WriteLine("Input hour of tv show");
  24.                 Int32.TryParse(Console.ReadLine(), out hour);
  25.                 Console.WriteLine("Input minute of tv show");
  26.                 Int32.TryParse(Console.ReadLine(), out minute);
  27.  
  28.                 Console.WriteLine("Input category of tv show");
  29.                 string category =  Console.ReadLine();
  30.  
  31.                 if (category.Length > 2)
  32.                 {
  33.                     Console.WriteLine("Incorrect category name");
  34.                     category = null;
  35.                 }
  36.  
  37.                 shows.Add(new TVShow(name, hour, minute, category));
  38.  
  39.                 var sorted = shows.OrderByDescending(s =>( s.Hours*60 + s.Minutes)).ToList();
  40.                 using (StreamWriter fout = new StreamWriter("output.txt"))
  41.                 {
  42.  
  43.                
  44.                     foreach (var t in sorted)
  45.                 {
  46.                     if (t.Category == "Π”Π€")
  47.                     {
  48.                         break;
  49.                     }
  50.  
  51.                         fout.WriteLine(t.Name);
  52.                      
  53.                     }
  54.                 }
  55.  
  56.  
  57.  
  58.                 }
  59.             while (Console.ReadKey().Key!=ConsoleKey.Escape);
  60.  
  61.         }
  62.     }
  63.  
  64.     class TVShow
  65.     {
  66.        public  string Name;
  67.        public  int Hours;
  68.        public  int Minutes;
  69.        public  string Category;
  70.  
  71.         public TVShow(string name, int hours, int minutes, string category)
  72.         {
  73.             Name = name;
  74.             hours = Hours;
  75.             minutes =  Minutes;
  76.             category = Category;
  77.         }
  78.  
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment