Ejemplo n.º 1
0
        public string SelectProduct(string input)
        {
            if (!Inventory.ContainsKey(input))
            {
                return("Bad item code! Please try again.");
            }
            else if (UserMoney < Inventory[input].Price)
            {
                return("Not enough money! Please insert more money.");
            }
            else if (Inventory[input].Quantity == 0)
            {
                return("That item is gone! Please select a different item.");
            }
            else
            {
                double startLog = UserMoney;

                Inventory[input].ConsumeItem();
                string changedItem = Inventory[input].Name;
                if (SalesCount.ContainsKey(changedItem))
                {
                    SalesCount[changedItem]++;
                }

                UserMoney -= Inventory[input].Price;
                Bank      += Inventory[input].Price;

                double endLog = UserMoney;
                ReadWriteData.WriteLog($"{Inventory[input].Name} {Inventory[input].Slot}", startLog, endLog);

                return(Inventory[input].ConsumeMessage);
            }
        }
Ejemplo n.º 2
0
        public void FeedMoney(int input)
        {
            double startLog = input;

            UserMoney += input;

            double endLog = UserMoney;

            ReadWriteData.WriteLog("FEED MONEY:", startLog, endLog);
        }
Ejemplo n.º 3
0
        public string MakeChange()
        {
            double startLog = UserMoney;

            UserMoney *= 100;

            if (UserMoney == 0)
            {
                return("");
            }

            int    cents = Convert.ToInt32(UserMoney);
            int    D     = 0;
            int    P     = 0;
            int    N     = 0;
            string coins = "";

            int Q = cents / 25;

            if (Q > 0)
            {
                if (Q == 1)
                {
                    coins += Q + " Quarter ";
                }
                else
                {
                    coins += Q + " Quarters ";
                }
                cents %= 25;
            }
            D = cents / 10;
            if (D > 0)
            {
                if (D == 1)
                {
                    coins += D + " Dime ";
                }
                else
                {
                    coins += D + " Dimes ";
                }
                cents %= 10;
            }
            N = cents / 5;
            if (N > 0)
            {
                if (N == 1)
                {
                    coins += N + " Nickel ";
                }
                else
                {
                    coins += N + " Nickels ";
                }
                cents %= 5;
            }
            P = cents;
            if (P > 0)
            {
                if (P == 1)
                {
                    coins += P + " Penny ";
                }
                else
                {
                    coins += P + " Pennies ";
                }
            }

            UserMoney          = 0;
            SalesCount["Bank"] = Convert.ToInt32(Bank * 100);
            ReadWriteData.WriteSales(SalesCount);
            double endLog = UserMoney;

            ReadWriteData.WriteLog("MAKE CHANGE:", startLog, endLog);
            return(coins + "returned.");
        }