Ejemplo n.º 1
0
        public void UangPecahan(decimal rupiah)
        {
            VendingFileWriter vfw = new VendingFileWriter();

            vfw.WriteToLog("Uang Pecahan :: Rp " + balance + " Rp " + (balance + rupiah));
            this.balance += rupiah;
        }
Ejemplo n.º 2
0
        public VendableItem Purchase(string slot)
        {
            if (!IsSoldOut(slot))
            {
                if (items[slot][0].Price <= this.balance)
                {
                    VendableItem      selection = items[slot][0];
                    VendingFileWriter vfw       = new VendingFileWriter();
                    vfw.WriteToLog($"{items[slot][0].Name} {slot} Rp " + balance + " Rp " + (balance - items[slot][0].Price));
                    balance -= items[slot][0].Price;
                    purchasedItems.Add(items[slot][0]);
                    items[slot].Remove(items[slot][0]);

                    return(selection);
                }
                else
                {
                    Console.WriteLine("Uang tidak mencukupi, silahkan deposit lagi.");
                    return(null);
                }
            }
            else
            {
                Console.WriteLine("Item terjual, silakan pilih item lain");
                return(null);
            }
        }
Ejemplo n.º 3
0
        public void CompleteTransaction()
        {
            ChangeMaker c = new ChangeMaker(this.balance);

            c.MakeChange();
            VendingFileWriter vfw = new VendingFileWriter();

            vfw.WriteToLog("Sisa kembalian : Rp " + balance);
            this.balance = 0;
            foreach (VendableItem e in purchasedItems)
            {
                Console.WriteLine(e.Consume());
            }
            purchasedItems.Clear();
        }