Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Linq;
- using System.IO;
- namespace ConsoleApplication6
- {
- class Program
- {
- static void Main(string[] args)
- {
- int hour;
- int minute;
- do {
- List<TVShow> shows = new List<TVShow>();
- Console.WriteLine("Input name of tv show");
- string name = Console.ReadLine();
- Console.WriteLine("Input hour of tv show");
- Int32.TryParse(Console.ReadLine(), out hour);
- Console.WriteLine("Input minute of tv show");
- Int32.TryParse(Console.ReadLine(), out minute);
- Console.WriteLine("Input category of tv show");
- string category = Console.ReadLine();
- if (category.Length > 2)
- {
- Console.WriteLine("Incorrect category name");
- category = null;
- }
- shows.Add(new TVShow(name, hour, minute, category));
- var sorted = shows.OrderByDescending(s =>( s.Hours*60 + s.Minutes)).ToList();
- using (StreamWriter fout = new StreamWriter("output.txt"))
- {
- foreach (var t in sorted)
- {
- if (t.Category == "ΠΠ€")
- {
- break;
- }
- fout.WriteLine(t.Name);
- }
- }
- }
- while (Console.ReadKey().Key!=ConsoleKey.Escape);
- }
- }
- class TVShow
- {
- public string Name;
- public int Hours;
- public int Minutes;
- public string Category;
- public TVShow(string name, int hours, int minutes, string category)
- {
- Name = name;
- hours = Hours;
- minutes = Minutes;
- category = Category;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment