static void Main(string[] args) { long bagCapacity = long.Parse(Console.ReadLine()); IBag bag = new Bag(bagCapacity); string[] safe = Console.ReadLine() .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < safe.Length; i += 2) { string name = safe[i]; long count = long.Parse(safe[i + 1]); string item = string.Empty; item = SelectItem(name); long bagOcupate = bag.OcupateBag; if (item == "Gold") { bag.Gold += count; } else if (item == "Gem") { bag.AddGem(name, count); } else if (item == "Cash") { bag.AddCash(name, count); } } Console.WriteLine(bag.PrintResult()); }
public static void Main() { int bagCapacity = int.Parse(Console.ReadLine()); string[] safeContent = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries); Bag bag = new Bag(bagCapacity); ItemCollector itemCollector = new ItemCollector(); itemCollector.CollectItems(bag, safeContent); bag.PrintResult(); }