Exemplo n.º 1
0
 private static void InsertItem(string key, long value, Bag bag)
 {
     if (key.Length == 3)
     {
         CashItem cash = new CashItem(key, value);
         bag.AddCashItem(cash);
     }
     else if (key.Length >= 4 && key.ToLower().EndsWith("gem"))
     {
         GemItem gem = new GemItem(key, value);
         bag.AddGemItem(gem);
     }
     else if (key.ToLower().Equals("gold"))
     {
         GoldItem gold = new GoldItem(key, value);
         bag.AddGoldItem(gold);
     }
 }
Exemplo n.º 2
0
        private static void InsertItem(Bag bag, string treasureName, long treasureAmount)
        {
            if (treasureName.Length >= 4 && treasureName.ToLower() == "gold")
            {
                Gold gold = new Gold(treasureName, treasureAmount);

                bag.AddGoldItem(gold);
            }
            else if (treasureName.Length >= 4 && treasureName.ToLower().EndsWith("gem"))
            {
                Gem gem = new Gem(treasureName, treasureAmount);

                bag.AddGemItem(gem);
            }
            else if (treasureName.Length == 3)
            {
                Cash cash = new Cash(treasureName, treasureAmount);

                bag.AddCashItem(cash);
            }
        }