Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _02._Friendlist_Maintenance
- {
- class Program
- {
- static void Main(string[] args)
- {
- var list = Console.ReadLine().Split(", ").ToList();
- int blacklistedNamesCount = 0;
- int lostNamesCount = 0;
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "Report")
- {
- break;
- }
- var tokens = input.Split();
- string command = tokens[0];
- switch (command)
- {
- case "Blacklist":
- string name = tokens[1];
- if (list.Contains(name))
- {
- blacklistedNamesCount++;
- Console.WriteLine($"{name} was blacklisted.");
- list[list.IndexOf(name)] = "Blacklisted";
- }
- else
- {
- Console.WriteLine($"{name} was not found.");
- }
- break;
- case "Error":
- int index = int.Parse(tokens[1]);
- name = list[index];
- if (index < list.Count && index >= 0 && list[index] != "Blacklisted" && list[index] != "Lost")
- {
- lostNamesCount++;
- Console.WriteLine($"{name} was lost due to an error.");
- list[index] = "Lost";
- }
- break;
- case "Change":
- index = int.Parse(tokens[1]);
- string currentName = list[index];
- string newName = tokens[2];
- if (index < list.Count && index >= 0)
- {
- list[index] = newName;
- Console.WriteLine($"{currentName} changed his username to {newName}.");
- }
- break;
- }
- }
- Console.WriteLine($"Blacklisted names: {blacklistedNamesCount}");
- Console.WriteLine($"Lost names: {lostNamesCount}");
- Console.WriteLine(string.Join(" ", list));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement