Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.05 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.  
  7. namespace _10.Exercises
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string input = Console.ReadLine();
  14.             var result = new List<Exercise>();
  15.  
  16.             while (input != "go go go")
  17.             {
  18.                 Exercise currExercise = ReadExercise(input);
  19.                 result.Add(currExercise);
  20.                 input = Console.ReadLine();
  21.             }
  22.  
  23.             int counter = 1;
  24.             foreach (var item in result)
  25.             {
  26.                 Console.WriteLine($"Exercises: {item.Topic}");
  27.                 Console.WriteLine($"Problems for exercises and homework for the \"{item.CourseName}\" course @ SoftUni.");
  28.                 Console.WriteLine($"Check your solutions here: {item.JudgeContestLink}");
  29.                 foreach (var prob in item.Problems)
  30.                 {
  31.                     Console.WriteLine($"{counter}. {prob}");
  32.                     counter++;
  33.                 }
  34.                
  35.             }
  36.         }
  37.  
  38.         private static Exercise ReadExercise(string input)
  39.         {
  40.             string[] tokens = input.Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  41.             string topic = tokens[0];
  42.             string courseName = tokens[1];
  43.             string link = tokens[2];
  44.             List<string> problems = tokens[3].Split(new string[] { ", " },
  45.                                 StringSplitOptions.RemoveEmptyEntries).ToList();
  46.  
  47.             return new Exercise
  48.             {
  49.                 Topic = topic,
  50.                 CourseName = courseName,
  51.                 JudgeContestLink = link,
  52.                 Problems = problems
  53.             };
  54.            
  55.         }
  56.     }
  57.     class Exercise
  58.     {
  59.         public string Topic { get; set; }
  60.         public string CourseName { get; set; }
  61.         public string JudgeContestLink { get; set; }
  62.         public List<string> Problems { get; set; }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement