Example #1
0
        /// <steal>
        ///  This method takes from the console information for a bank robbery.
        ///  (amount money to steal, bank name)
        ///  It increases the balance with the specified amount,
        ///  and prints the name of the robbed bank.
        /// </steal>
        public void Steal()
        {
            double amount;
            string bank;

            try
            {
                Dictionary <string, string> dict = CommandReader.Steal();

                if (dict["bank"] == "" || dict["amount"] == "")
                {
                    throw new InvalidOperationException(ConstantStrings.Blank);
                }

                try
                {
                    amount = double.Parse(dict["amount"]);
                }
                catch (Exception)
                {
                    throw new InvalidOperationException(ConstantStrings.Amount + " " + ConstantStrings.ValidNumber);
                }

                bank = dict["bank"];

                OutputPrinter.Connecting();
                money.Money_Amount += amount;
                c.SaveChanges();
                OutputPrinter.Done();

                OutputPrinter.Steal(bank);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                OutputPrinter.InvalidCommand();
            }
        }