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