Advertisement
Guest User

Untitled

a guest
Jan 30th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace Tasks_Planner
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<int> tasks = Console.ReadLine()
  12. .Split(" ")
  13. .Select(int.Parse)
  14. .ToList();
  15.  
  16. string input;
  17. while ((input = Console.ReadLine()) != "End")
  18. {
  19. string[] inputArgs = input
  20. .Split(" ");
  21.  
  22. string command = inputArgs[0];
  23.  
  24. if (command != "Count")
  25. {
  26. int index = int.Parse(inputArgs[1]);
  27. bool indexExists = index >= 0 && index < tasks.Count;
  28.  
  29. if (command == "Complete")
  30. {
  31. if (indexExists)
  32. {
  33. tasks[index] = 0;
  34. }
  35. }
  36. else if (command == "Change")
  37. {
  38. int time = int.Parse(inputArgs[2]);
  39. if (time < 1 || time > 5)
  40. {
  41. break;
  42. }
  43. if (indexExists)
  44. {
  45. tasks[index] = time;
  46. }
  47. }
  48. else if (command == "Drop")
  49. {
  50. if (indexExists)
  51. {
  52. tasks[index] = -1;
  53. }
  54. }
  55. }
  56. else
  57. {
  58. string typeOfTasks = inputArgs[1];
  59. switch (typeOfTasks)
  60. {
  61. case "Completed":
  62. List<int> comlpeted = tasks.FindAll(x => x == 0);
  63. int countOfCompletedTasks = comlpeted.Count;
  64. Console.WriteLine(countOfCompletedTasks);
  65. break;
  66. case "Incompleted":
  67. List<int> incompleted = tasks.FindAll(x => x > 0);
  68. int countOfIncompleted = incompleted.Count;
  69. Console.WriteLine(countOfIncompleted);
  70. break;
  71. case "Dropped":
  72. List<int> dropped = tasks.FindAll(x => x == -1);
  73. int countOfDropped = dropped.Count;
  74. Console.WriteLine(countOfDropped);
  75. break;
  76. }
  77. }
  78. }
  79. List<int> incompleteItems = tasks.FindAll(x => x > 0);
  80. Console.WriteLine(String.Join(" ", incompleteItems));
  81. }
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement