Ejemplo n.º 1
0
        internal void VoegStockToe(DrankStock drank)
        {
            bool naamCheck = false;
            int  tel       = 0;

            for (int i = 0; i < Stock.Length; i++)
            {
                if (drank.NaamDrank == Stock[i].NaamDrank)
                {
                    tel       = i;
                    naamCheck = true;
                }
            }
            if (naamCheck)
            {
                Stock[tel].Aantal += drank.Aantal;
            }
            else
            {
                DrankStock[] tempStock = new DrankStock[Stock.Length + 1];
                for (int i = 0; i < tempStock.Length - 1; i++)
                {
                    tempStock[i] = Stock[i];
                }
                tempStock[tempStock.Length - 1] = drank;
                Stock = tempStock;
            }
        }
Ejemplo n.º 2
0
        internal void VoegStockToe()
        {
            Console.WriteLine("Wat wilt u toevoegen?");
            Console.WriteLine("Geef naam, prijs en aantal in.");
            Console.WriteLine();
            string[]   input       = Console.ReadLine().Split(',');
            DrankStock nieuweDrank = new DrankStock(input[0], Convert.ToDecimal(input[1]), Convert.ToInt32(input[2]));

            VoegStockToe(nieuweDrank);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            DrankAutomaat automaat = new DrankAutomaat();

            DrankStock cola = new DrankStock("Cola", 0.9M, 50);

            automaat.VoegStockToe(cola);
            DrankStock fanta = new DrankStock("Fanta", 1.1M, 1);

            automaat.VoegStockToe(fanta);

            int input = 0;

            do
            {
                Console.WriteLine("Wat wil u doen?");
                Console.WriteLine("1) Toon beschikbare dranken.");
                Console.WriteLine("2) Steek geld in automaat.");
                Console.WriteLine("3) Koop een drank.");
                Console.WriteLine("4) Voeg drank toe.");

                Console.WriteLine("9) Quit.");
                Console.WriteLine();
                input = int.Parse(Console.ReadLine());

                switch (input)
                {
                case 1:
                    automaat.ToonBeschikbareDranken();
                    break;

                case 2:
                    Console.WriteLine("Geef in hoeveel.");
                    decimal hoeveel = decimal.Parse(Console.ReadLine());
                    automaat.SteekGeldInAutomaat(hoeveel);
                    break;

                case 3:
                    automaat.KoopDrank();
                    break;

                case 4:
                    automaat.VoegStockToe();
                    break;

                default:
                    break;
                }
            } while (input != 9);
        }
Ejemplo n.º 4
0
 public DrankAutomaat()
 {
     Stock = new DrankStock[0];
 }