public void TakeMoney(Bill bill)
 {
     if(cash.ContainsKey((int)bill))
     {
         cash[(int)bill]++;
     }
     else
     {
         cash.Add((int)bill, 1);
     }
 }
Ejemplo n.º 2
0
        public string GiveChange()
        {
            int total = 0;
            string change = string.Empty;
            for (int i = 0; i < Coins.Count; i++)
            {
                total += Coins[i].Value;
            }
            if (total > 100)
            {
                int bill = total / 100;
                Bill bil = new Bill(bill);
                int coins = total % 100;
                Coin coin = new Coin(coins);
                change = bil.ToString() + "and " + coin.ToString();
            }

            return change;
        }
Ejemplo n.º 3
0
        public BatchBill(Bill[] bills): this(bills.ToList())
        {

        }
Ejemplo n.º 4
0
 public int Value(Bill bill)
 {
     int val = 0;
     val = bill.bill;
     Console.WriteLine("The bill value is +" + bill.bill);
     return val;
 }
Ejemplo n.º 5
0
 public void TakeMoney(Bill gates)
 {
     Money.Add(gates);
 }
Ejemplo n.º 6
0
 private static Bill TurningItemPriceIntoBills(decimal price)
 {
     int floor = (int)Math.Floor(price);
     Bill biil = new Bill(floor);
     string takeCoins = (price % 1).ToString();
     takeCoins = takeCoins.Remove(0, 2);
     Coin coins = new Coin(int.Parse(takeCoins));
     BatchCoins batchcoins = new BatchCoins(new List<Coin>() { coins });
     Bill batchttt = batchcoins.GiveBill();
     biil = biil + batchttt;
     return biil;
 }
Ejemplo n.º 7
0
 private static void ConsoleCommands(CashDesk desk)
 {
     while (true)
     {
         Item item = new Item();
         string[] input = Console.ReadLine().Split(new char[] { ' ' });
         if (input[0] == Command.exit.ToString())
         {
             return;
         }
         else if (input[0] == Command.takebill.ToString())
         {
             int validate = int.Parse(input[1]);
             Validate(ref validate);
             Bill bill = new Bill(validate);
             desk.TakeMoney(bill);
         }
         else if (input[0] == Command.takebatch.ToString())
         {
             Bill[] bill = new Bill[input.Length - 1];
             int validete = 0;
             for (int i = 0; i < input.Length - 1; i++)
             {
                 validete = int.Parse(input[i + 1]);
                 Validate(ref validete);
                 bill[i] = new Bill(validete);
             }
             BatchBill batch = new BatchBill(bill);
             desk.TakeMoney(batch);
         }
         else if (input[0] == Command.total.ToString())
         {
             Console.WriteLine(desk.Total());
         }
         else if (input[0] == Command.inspect.ToString())
         {
             desk.Inspect();
         }
         else if (input[0] == Command.takecoins.ToString())
         {
             Coin[] coin = new Coin[input.Length - 1];
             for (int i = 1; i < coin.Length - 1; i++)
             {
                 coin[i] = new Coin(int.Parse(input[i + 1]));
             }
             BatchCoins coins = new BatchCoins(coin);
             desk.TakeMoney(coins);
         }
         else if (input[0] == Command.sellitem.ToString())
         {
             item = new Item(decimal.Parse(input[2]));
         }
         else if (input[0] == Command.buyitem.ToString())
         {
             if (decimal.Parse(input[2]).Equals(item.Price))
             {
                 Console.WriteLine("Thanks");
             }
             else if (decimal.Parse(input[2]) >= item.Price)
             {
                 Bill turned =  TurningItemPriceIntoBills(item.Price);
                 Console.WriteLine(turned.Value-item.Price);
             }
         }
         else
         {
             Console.WriteLine("Wrong command");
         }
     }
 }
Ejemplo n.º 8
0
 private static void Tests()
 {
     var bills = new Bill[] { new Bill(10), new Bill(20), new Bill(50), new Bill(100), new Bill(100) };
     var batch = new BatchBill(bills);
     CashDesk desk = new CashDesk();
     desk.TakeMoney(batch);
     desk.TakeMoney(new Bill(100));
     desk.TakeMoney(new Bill(10));
     desk.Inspect();
 }
Ejemplo n.º 9
0
 public static Bill operator +(Bill one, Bill two)
 {
     Bill sum = new Bill(one.Value + two.Value);
     return sum;
     
 }