Exemplo n.º 1
0
 /// <summary>
 /// This takes the needed change away from the count, actuates the dispenser, and changes the text box
 /// </summary>
 /// <param name="countNeeded">This is the number of coins of this type needed</param>
 /// <returns>If there aren't enough coins, return the value that wasn't covered</returns>
 public int SubtractChange(int countNeeded)
 {
     if (count < countNeeded)
     {
         dispenser.Actuate(count);
         int returner = (countNeeded * value) - (count * value);
         count = 0;
         return(returner);
     }
     count -= countNeeded;
     dispenser.Actuate(countNeeded);
     return(0);
 }
Exemplo n.º 2
0
        /// <summary>
        /// reduces the number of coins
        /// </summary>
        /// <param name="money">the money in the machine</param>
        /// <returns>the money returned</returns>
        public int ReduceCoins(int money)
        {
            int x       = Convert.ToInt32(Math.Floor(Convert.ToDecimal(money / value))); //calculates the number of coin going to be returned
            int counter = 0;

            while (x > 0 && amount > 0)
            {
                amount--;
                counter++;
                x--;
            }

            coinD.Actuate(counter);
            return(counter * value);
        }
Exemplo n.º 3
0
 /// <summary>
 /// dispenses coins based on the number of coins to return calculated in getmaxReturn method and adjusts the number of coins and coins to return
 /// </summary>
 public void DispenceCoins()
 {
     coinDispenser.Actuate(NumCoinsToReturn);
     numCoins        -= NumCoinsToReturn;
     NumCoinsToReturn = 0;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Dispenses change based on the value determined in DetermineCoinsToDispense.
 /// </summary>
 public void DispenseChange()
 {
     coinDispenser.Actuate(numberToDispense);
     numCoins        -= numberToDispense;
     numberToDispense = 0;
 }
Exemplo n.º 5
0
 public void ReturnCoins()
 {
     coinDispenser.Actuate(numCoinsToReturn);
     numCoins -= numCoinsToReturn;
 }
Exemplo n.º 6
0
 public void coinDispense()
 {
     count -= coinDispenserCount;
     coinDispenser.Actuate(coinDispenserCount);
     coinDispenserCount = 0;
 }
Exemplo n.º 7
0
 public void dispenseChange()
 {
     numCoins -= coinsToReturn;
     coinDispenser.Actuate(coinsToReturn);
 }