与方法C#wpf中的结果比较 [英] Comparing to results in method C# wpf

查看:88
本文介绍了与方法C#wpf中的结果比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目是自动售货机:
但是我在比较代码时遇到问题:

有一个用于选择饮料的按钮,如果单击饮料,价格上会带有标签:

饮料示例代码:

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;
    }
}



现在我似乎无法对结果进行比较或做任何事情?
如果价格相同或更高,则groupbox1会引起很多人的点击,如果价格相同或更高,您仍然可以单击按钮,不要添加硬币.



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.

推荐答案

为什么要比较标签值?那真是糟糕的形式.您发布的代码根本没有任何意义.
Why are you comparing label values? That''s really bad form. The code you posted doesn''t make any sense at all.


这篇关于与方法C#wpf中的结果比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆