petyaminkova91

Untitled

Nov 1st, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace LecturePractice
  6. {
  7. public class Program
  8. {
  9. public class Article
  10. {
  11. public string Title { get; set; }
  12.  
  13. public string Content { get; set; }
  14.  
  15. public string Author { get; set; }
  16. }
  17. public static void Main()
  18. {
  19. var inputText = Console.ReadLine()
  20. .Split(", ")
  21. .ToList();
  22.  
  23. var number = int.Parse(Console.ReadLine());
  24.  
  25. var article = new Article
  26. {
  27. Title = inputText[0],
  28. Content = inputText[1],
  29. Author = inputText[2]
  30. };
  31.  
  32. for (int i = 0; i < number; i++)
  33. {
  34. var newInput = Console.ReadLine()
  35. .Split(":")
  36. .Select(s => s.Trim())
  37. .ToList();
  38.  
  39. if (newInput[0] == "Edit")
  40. {
  41. article.Content = newInput[1];
  42. }
  43. else if (newInput[0] == "ChangeAuthor")
  44. {
  45. article.Author = newInput[1];
  46. }
  47. else if (newInput[0] == "Rename")
  48. {
  49. article.Title = newInput[1];
  50. }
  51. }
  52.  
  53. Console.WriteLine($"{article.Title} - {article.Content}: {article.Author}");
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment