Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Junk
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> inventory = Console.ReadLine().Split().ToList();
- List<string> command = Console.ReadLine().Split().ToList();
- while (command[0] != "Fight!")
- {
- if (command[0] == "Buy")
- {
- if (inventory.Contains(command[1]) == false)
- {
- inventory.Add(command[1]);
- }
- }
- if (command[0] == "Trash")
- {
- if (inventory.Contains(command[1]))
- {
- inventory.Remove(command[1]);
- }
- }
- if (command[0] == "Repair")
- {
- if (inventory.Contains(command[1]))
- {
- inventory.Remove(command[1]);
- inventory.Add(command[1]);
- }
- }
- if (command[0] == "Upgrade")
- {
- List<string> tokens = command[1].Split('-').ToList();
- int index = inventory.IndexOf(tokens[0]);
- if (index != -1)
- {
- inventory.Insert(index + 1, string.Join(":", tokens));
- }
- }
- command = Console.ReadLine().Split().ToList();
- }
- Console.WriteLine(string.Join(" ", inventory));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement