Advertisement
petarkobakov

Task Planner

Jul 3rd, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  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. string command = Console.ReadLine();
  16. int completed = 0;
  17. int incompleted = 0;
  18. int dropped = 0;
  19.  
  20. while (command!="End")
  21. {
  22. string[] elements = command.Split();
  23. string toDo = elements[0];
  24.  
  25. if (toDo == "Complete")
  26. {
  27. int index = int.Parse(elements[1]);
  28. if (index >= 0 && index < tasks.Count)
  29. {
  30. tasks[index] = 0;
  31.  
  32. }
  33. }
  34. else if (toDo == "Change")
  35. {
  36. int index = int.Parse(elements[1]);
  37. int value = int.Parse(elements[2]);
  38.  
  39. if (index >= 0 && index < tasks.Count)
  40. {
  41. tasks[index] = value;
  42. }
  43. }
  44. else if (toDo == "Drop")
  45. {
  46. int index = int.Parse(elements[1]);
  47. if (index >= 0 && index < tasks.Count)
  48. {
  49. tasks[index] = -1;
  50. }
  51. }
  52. else if (toDo == "Count")
  53. {
  54. string status = elements[1];
  55. if (status == "Completed")
  56. {
  57. for (int i = 0; i < tasks.Count; i++)
  58. {
  59. if (tasks[i] == 0)
  60. {
  61. completed++;
  62. }
  63. }
  64. Console.WriteLine(completed);
  65. }
  66. else if (status == "Incomplete")
  67. {
  68. for (int i = 0; i < tasks.Count; i++)
  69. {
  70. if (tasks[i] > 0)
  71. {
  72. incompleted++;
  73. }
  74. }
  75. Console.WriteLine(incompleted);
  76. }
  77. else if (status == "Dropped")
  78. {
  79. for (int i = 0; i < tasks.Count; i++)
  80. {
  81. if (tasks[i] < 0)
  82. {
  83. dropped++;
  84. }
  85. }
  86. Console.WriteLine(dropped);
  87. }
  88.  
  89. }
  90. command = Console.ReadLine();
  91. }
  92.  
  93. for (int i = 0; i < tasks.Count; i++)
  94. {
  95. if (tasks[i] > 0)
  96. {
  97. Console.Write(tasks[i]+" ");
  98. }
  99. }
  100.  
  101.  
  102. }
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement