Exemplo n.º 1
0
        public override bool Equals(object obj)
        {
            AdvancedItems other = obj as AdvancedItems;

            if (other == null)
            {
                return(false);
            }
            else if (this.Value == other.Value)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        static void Main()
        {
            var chemical  = new Queue <int>(getIntegerInput());
            var physical  = new Stack <int>(getIntegerInput());
            var materials = setAdvancedItems();

            while (chemical.Count > 0 && physical.Count > 0)
            {
                var sum         = chemical.Dequeue() + physical.Peek();
                var checkedItem = new AdvancedItems("", sum);
                if (materials.ContainsKey(checkedItem))
                {
                    materials[checkedItem]++;
                    physical.Pop();
                }
                else
                {
                    physical.Push(physical.Pop() + 3);
                }
            }

            if (materials.All(x => x.Value > 0))
            {
                Console.WriteLine("Wohoo! You succeeded in building the spaceship!");
            }
            else
            {
                Console.WriteLine("Ugh, what a pity! You didn't have enough materials to build the spaceship.");
            }
            Console.Write("Liquids left: ");
            Console.WriteLine((chemical.Count == 0) ? "none" : string.Join(", ", chemical));
            Console.Write("Physical items left: ");
            Console.WriteLine((physical.Count == 0) ? "none" : string.Join(", ", physical));
            foreach (var item in materials.OrderBy(x => x.Key.Name))
            {
                Console.WriteLine($"{item.Key.Name}: {item.Value}");
            }
        }