private static void InsertItem(string key, long value, bag bag) { if (key.Length == 3) { cash cash = new cash(key, value); bag.AddCashItem(cash); } else if (key.Length >= 4 && key.ToLower().EndsWith("gem")) { gem gem = new gem(key, value); bag.AddGemItem(gem); } else if (key.ToLower().Equals("gold")) { gold gold = new gold(key, value); bag.AddGoldItem(gold); } }