Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a project that is a vending machine:
But i have a problem comparing code:

There a buttons for choosing the drink and it has the prices to a label if clicked on the drink:

example code drink:

private void btnCola_Click(object sender, RoutedEventArgs e)
{
    Drank d;
    d = new Drank();
    double cola = d.coladrank();
    lblSortDrink.Content = cola;
    groupBox2.IsEnabled = true;
}
(Drank is sort drink)

i made class of this

partial class Drank
{
    public int cola;
    public int water;
    public int koffie;
    public int soep;

    public double coladrank()
    { 
        double cola = 1.00;
        return cola;
    }
}


The coin button become enable if clicked and stop when there is enough money. example code:

private void btnTwo_Click(object sender, RoutedEventArgs e)
{
    Geld g;
    g = new Geld();
    double tweeEuro = g.tweeEurogeld();
            
    if (Convert.ToDouble(lblSortDrink.Content) > (Convert.ToDouble((lblInsertedCoins.Content))))
    {
        result += tweeEuro;
        lblInsertedCoins.Content = result;
    }
    else
    {
        groupbox1.IsEnable = false;
    }
}


again i made a class of the coins:

partial class Geld
{
    public int tweeEuro;
    public int eenEuro;
    public int vijtigCent;
    public int twintigCent;
    public int tienCent;
    public int vijfCent;

    public double tweeEurogeld()
    {
        double tweeEuro = 2.00;
        return tweeEuro;
    }
}


now i cant seem to compare or do anything with the results?
and the groupbox1 is a click to many bacause if the price is the same or bigger you can still click the button do'h the coins dont add.

Posted
Updated 17-Jan-10 2:49am
v2

1 solution

Why are you comparing label values? That's really bad form. The code you posted doesn't make any sense at all.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900