Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ShoppingList
- {
- class Program
- {
- static void Main(string[] args)
- {
- var list = Console.ReadLine().Split('!').ToList();
- string input;
- while ((input = Console.ReadLine()) != "Go Shopping!")
- {
- var tokens = input.Split(' ');
- string command = tokens[0];
- string product = tokens[1];
- if (command == "Urgent" && !list.Contains(product))
- {
- list.Insert(0, product);
- }
- else if (command == "Unnecessary" && list.Contains(product))
- {
- list.Remove(product);
- }
- else if (command == "Correct" && list.Contains(product))
- {
- string newProduct = tokens[2];
- list[list.IndexOf(product)] = newProduct;
- }
- else if (command == "Rearrange" && list.Contains(product))
- {
- list.Remove(product);
- list.Add(product);
- }
- }
- Console.WriteLine(String.Join(", ", list));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement