Esempio n. 1
0
        static void Main(string[] args)
        {
            long capacity = long.Parse(Console.ReadLine());

            string[] vault = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            var bag = new Bag();

            for (int i = 0; i < vault.Length; i += 2)
            {
                string name   = vault[i];
                long   amount = long.Parse(vault[i + 1]);

                if (name.Length == 3)
                {
                    AddCash(bag, name, amount, capacity);
                }
                else if (name.ToLower() == "gold")
                {
                    AddGold(bag, amount, capacity);
                }
                else if (name.ToLower().EndsWith("gem"))
                {
                    AddGems(bag, name, amount, capacity);
                }
            }

            if (bag.Gold.Any())
            {
                Console.WriteLine(bag.ToString().TrimEnd());
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            long bagCapacity = long.Parse(Console.ReadLine());

            string[] safeContent = Console.ReadLine()
                                   .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            Bag myBag = new Bag(bagCapacity);

            StealingRichies(safeContent, myBag);

            Console.WriteLine(myBag.ToString());
        }
Esempio n. 3
0
        static void Main()
        {
            long capacity = long.Parse(Console.ReadLine());

            string[] safe = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            Bag      bag  = new Bag(capacity);

            for (int i = 0; i < safe.Length; i += 2)
            {
                string itemName = safe[i];
                long   amount   = long.Parse(safe[i + 1]);
                bag.AddItem(itemName, amount);
            }

            Console.WriteLine(bag.ToString());
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            long capacity = long.Parse(Console.ReadLine());
            var  input    = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);
            var  bag      = new Bag(capacity);

            for (int i = 0; i < input.Length; i += 2)
            {
                string key   = input[i];
                long   value = long.Parse(input[i + 1]);

                InsertItem(key, value, bag);
            }

            Console.WriteLine(bag.ToString());
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            long capacity = long.Parse(Console.ReadLine());

            string[] safe = Console.ReadLine()
                            .Split(" ", StringSplitOptions.RemoveEmptyEntries);

            Bag bag = new Bag(capacity);

            for (int i = 0; i < safe.Length; i += 2)
            {
                string key   = safe[i];
                int    value = int.Parse(safe[i + 1]);

                InsertItem(bag, key, value);
            }

            Console.WriteLine(bag.ToString());
        }
 public void Output()
 {
     Console.WriteLine(bag.ToString());
 }