Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Tasks_Planner
- {
- class Program
- {
- static void Main()
- {
- var taskList = Console.ReadLine().Split().ToList();
- string input = Console.ReadLine();
- while(input != "End")
- {
- List<string> command = input.Split().ToList();
- if (command[0] == "Complete" && IsIndexExist(taskList, command))
- {
- int taskIndex = int.Parse(command[1].ToString());
- taskList[taskIndex] = "0";
- }
- else if (command[0] == "Change" && IsIndexExist(taskList, command))
- {
- int taskIndex = int.Parse(command[1].ToString());
- taskList[taskIndex] = command[2];
- }
- else if (command[0] == "Drop" && IsIndexExist(taskList, command))
- {
- int taskIndex = int.Parse(command[1].ToString());
- taskList[taskIndex] = "-1";
- }
- else if(command[0] == "Count")
- {
- if (command[1] == "Completed")
- {
- int count = 0;
- foreach (var item in taskList.Where(i => i == "0"))
- {
- count++;
- }
- Console.WriteLine(count);
- }
- else if (command[1] == "Incomplete")
- {
- int count = 0;
- foreach (var item in taskList.Where(i => i != "0" && i != "-1"))
- {
- count++;
- }
- Console.WriteLine(count);
- }
- else if (command[1] == "Dropped")
- {
- int count = 0;
- foreach (var item in taskList.Where(i => i == "-1"))
- {
- count++;
- }
- Console.WriteLine(count);
- }
- }
- input = Console.ReadLine();
- }
- List<string> newList = new List<string>();
- foreach (var item in taskList.Where(i => i != "0" && i != "-1"))
- {
- newList.Add(item);
- }
- Console.WriteLine(string.Join(" ", newList));
- }
- static bool IsIndexExist(List<string> taskList, List<string> command)
- {
- bool isIndexExist = false;
- int index = int.Parse(command[1].ToString());
- if (index >= 0 && index < taskList.Count)
- {
- isIndexExist = true;
- }
- return isIndexExist;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement