Vnding machine project pronlems


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Vnding machine project pronlems

Hybrid View

  1. #1
    Join Date
    Dec 2009
    Posts
    2

    Vnding machine project pronlems

    Having a few problems with a small project c# WPF
    Most of my buttons work and create reports
    But m method of the insert coins doesnt work cauze i can only click once on a coin.
    An overview of the program.
    The Flow of the project.
    1.The Report "Choose" shown on the screen on start window.2.User chooses Drink /Coke/Water/Coffie/Beer// The choice is made by clicking on of the drinks in Make a Choice The drink and price displays next to the "current choice". The Report changes from choose to Pay.3.The user can now click on the Coin Buttons //2/1/0.50/0.20/0.10/0.05Euro// the total of the coin insert is displays next to the inserted coin(s)4.When there is enough money inserted the coin buttons become inactive. and the button Buy drink becomes active the Report changes to buy drink5.Afther the user clicks Buy drink The report changes to "take drink" below report there is another report given: -Take your "chosen drink" -money back "the money that is more than the price of the drink" -the total coin given back The button Take Drink becomes visble And all the rest of the buttons become inactive
    6.After the user clicks on take drink the program starts again. Note: Till point 4, the user can still change drink.So the If the drinks changes price and the inserted coins are blow or more than the chosen drink The Report changes also Pay or BuyPrices are Coke 0,50 /Water0,60 /Coffie 1,20 / Beer 4
    pic: http://img338.imageshack.us/img338/5...tdrinkvend.jpg

  2. #2
    Join Date
    Dec 2009
    Posts
    2

    Got a bit futher but still having probs

    Got a bit futhere but now each time if i press the coin button it disables a click to late.
    Examle when the inserted coin reach the same/Bigger rate you need to click it one more time before it disables.

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    
    namespace Drankmaatje
    {
        /// <summary>
        /// Interaction logic for Window1.xaml
        /// </summary>
        public partial class Window1 : Window
        {
            decimal cola;
            decimal water;
            decimal koffie;
            decimal soep;
            decimal tweeEuro;
            decimal eenEuro;
            decimal vijtigCent;
            decimal twintigCent;
            decimal tienCent;
            decimal vijfCent;
            decimal keuze;
            decimal verschil;
            decimal totaal;
    
            public Window1()
            {
                InitializeComponent();
            }
    
            private void btnCola_Click(object sender, RoutedEventArgs e)
            {
                cola = 0.60M;
                keuze = cola;
                lblKeuze.Content = keuze;
                gbGeldInworp.IsEnabled = true;
                lblStatus.Content = "Betaal";
    
            }
    
            private void btnWater_Click(object sender, RoutedEventArgs e)
            {
                water = 0.50M;
                keuze = water;
                lblKeuze.Content = keuze;
                gbGeldInworp.IsEnabled = true;
                lblStatus.Content = "Betaal";
    
    
            }
    
            private void btnkoffie_Click(object sender, RoutedEventArgs e)
            {
                koffie = 1.50M;
                keuze = koffie;
                lblKeuze.Content = keuze;
                gbGeldInworp.IsEnabled = true;
                lblStatus.Content = "Betaal";
            }
    
            private void btnsoep_Click(object sender, RoutedEventArgs e)
            {
                soep = 4.50M;
                keuze = soep;
                lblKeuze.Content = keuze;
                gbGeldInworp.IsEnabled = true;
                lblStatus.Content = "Betaal";
            }
    
            private void btnTweeEuro_Click(object sender, RoutedEventArgs e)
            {
                btnCancel.IsEnabled = true;
                tweeEuro = 2.00M;
                if (keuze >= totaal)
                    totaal = totaal + tweeEuro;
                else
                    btnKoop.IsEnabled = true;
                lblTotaalInwerp.Content = totaal;
                lblStatus.Content = "Koop";
    
            }
    
            private void btnEenEuro_Click(object sender, RoutedEventArgs e)
            {
                btnCancel.IsEnabled = true;
    
                eenEuro = 1.00M;
                if (keuze >= totaal)
                    totaal = totaal + eenEuro;
                else
                    btnKoop.IsEnabled = true;
                lblTotaalInwerp.Content = totaal;
                lblStatus.Content = "Koop";
    
    
            }
    
            private void btnVijtigCent_Click(object sender, RoutedEventArgs e)
            {
                btnCancel.IsEnabled = true;
                vijtigCent = 0.50M;
                if (keuze >= totaal)
                    totaal = totaal + vijtigCent;
                else
                    btnKoop.IsEnabled = true;
                lblTotaalInwerp.Content = totaal;
    
                lblStatus.Content = "Koop";
            }
    
            private void btnTwintigCent_Click(object sender, RoutedEventArgs e)
            {
                btnCancel.IsEnabled = true;
                twintigCent = 0.20M;
                if (keuze >= totaal)
                    totaal = totaal + twintigCent;
                else
                    btnKoop.IsEnabled = true;
                lblTotaalInwerp.Content = totaal;
                lblStatus.Content = "Koop";
            }
    
            private void btnTienCent_Click(object sender, RoutedEventArgs e)
            {
                btnCancel.IsEnabled = true;
                tienCent = 0.10M;
                if (keuze >= totaal)
                    totaal = totaal + tienCent;
                else
                    btnKoop.IsEnabled = true;
                lblTotaalInwerp.Content = totaal;
                lblStatus.Content = "Koop";
            }
    
            private void btnVijfCent_Click(object sender, RoutedEventArgs e)
            {
                btnCancel.IsEnabled = true;
                vijfCent = 0.05M;
                
                if (keuze >= totaal)
                    totaal = totaal + vijfCent;
                else
                    btnKoop.IsEnabled = true;
                lblTotaalInwerp.Content = totaal;
                lblStatus.Content = "Koop";
                   
            }
    
            private void btnKoop_Click(object sender, RoutedEventArgs e)
            {
                gbGeldInworp.IsEnabled = false;
                gbKeuzeDrank.IsEnabled = false;
                btnCancel.IsEnabled = false;
                btnKoop.IsEnabled = false;
                lblStatus.Content = "Neem";
    
                int count2E = 0;
                int count1E = 0;
                int count50C = 0;
                int count20C = 0;
                int count10C = 0;
                int count5C = 0;
    
                verschil = totaal - keuze;
                /* lblMelding.Content = verschil;*/
    
    
                do
                {
                    if (verschil >= 2M)
                    {
                        count2E++;
                        verschil = verschil - 2M;
                    }
    
                    else if (verschil >= 1M)
                    {
                        count1E++;
                        verschil = verschil - 1M;
                    }
    
                    else if (verschil >= 0.50M)
                    {
                        count50C++;
                        verschil = verschil - 0.50M;
                    }
    
                    else if (verschil >= 0.20M)
                    {
                        count20C++;
                        verschil = verschil - 0.20M;
                    }
    
                    else if (verschil >= 0.10M)
                    {
                        count10C++;
                        verschil = verschil - 0.10M;
                    }
    
                    else if (verschil >= 0.05M)
                    {
                        count5C++;
                        verschil = verschil - 0.05M;
                    }
                    else
                    {
                    }
    
                } while (verschil != 0);
                {
                    if (count2E != 0)
                    listBox1.Items.Add(count2E + " x 2 Euro ");
                    if (count1E != 0)
                    listBox1.Items.Add(count1E + " x 1 Euro ");
                    if (count50C != 0)
                    listBox1.Items.Add(count50C + " x 50Cent ");
                    if (count20C != 0)
                    listBox1.Items.Add(count20C + " x 20Cent ");
                    if (count10C != 0)
                    listBox1.Items.Add(count10C + " x 10Cent ");
                    if (count5C != 0)
                    listBox1.Items.Add(count5C + " x 5 Cent");
                    btnNeemDrank.Visibility = Visibility.Visible;
    
    
    
    
    
    
    
                }
            }
            
            private void Window_Loaded(object sender, RoutedEventArgs e)
            {
                gbGeldInworp.IsEnabled = false;
                btnCancel.IsEnabled = false;
                btnKoop.IsEnabled = false;
                btnNeemDrank.Visibility = Visibility.Hidden;
                lblStatus.Content = "Kies";
            }
    
            private void btnCancel_Click(object sender, RoutedEventArgs e)
            {
                gbGeldInworp.IsEnabled = false;
                btnCancel.IsEnabled = false;
                btnKoop.IsEnabled = false;
                lblKeuze.Content = "";
                lblStatus.Content = "Kies";
                lblTotaalInwerp.Content= "";
               
                
                
                
            }
    
            private void btnNeemDrank_Click(object sender, RoutedEventArgs e)
            {
                gbGeldInworp.IsEnabled = false;
                gbKeuzeDrank.IsEnabled = true;
                btnCancel.IsEnabled = false;
                btnKoop.IsEnabled = false;
                lblStatus.Content = "Kies";
                lblKeuze.Content = "";
                lblTotaalInwerp.Content = "";
                btnNeemDrank.Visibility = Visibility.Hidden;
                listBox1.Items.Clear();
    
            }
    
        }
    }

Similar Threads

  1. Replies: 1
    Last Post: 07-16-2007, 10:42 AM
  2. Long, basic Java Question.
    By Tom in forum Java
    Replies: 0
    Last Post: 03-18-2002, 10:25 AM
  3. Good Editorial by Russell Jones
    By Robert G in forum .NET
    Replies: 84
    Last Post: 02-08-2001, 02:38 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center