Problem with INT

  • Thread starter Thread starter MesikaX
  • Start date Start date
M

MesikaX

Guest
Hey, I'm trying to do a button that <g class="gr_ gr_101 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="101" id="101">everytime</g> you click on him its double the number value (money value).

But, there is a catch, I use random to random an event that Reset the Value to 1.

I got a problem with the code, he is working well sometimes and sometimes doesn't to the math good. (I create saved <g class="gr_ gr_73 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="73" id="73">moneybalance</g> that located and count your money balance and every time you push the button that adds <g class="gr_ gr_89 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" data-gr-id="89" id="89">your money</g> that you achieve from pressing the button to the correct balance but its sometimes do a wrong math and sometimes its reset the value or do a something that <g class="gr_ gr_148 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" data-gr-id="148" id="148">make</g> the Balance less.

I'm <g class="gr_ gr_194 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" data-gr-id="194" id="194">beginner</g> so I think the code it's not so complicated but I hope you can help me to find my bug.

Thank you <3




Thank you <3



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 WpfApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
int t1; //value in the button

int balance; //balance from the button

int a; //random_num

int savedbalance; //currect balance, (He gets
+_balance with click on button)

public MainWindow()
{
InitializeComponent();
t1 = 1;
Money.FontSize = 72; //money= labelname
Money.FontWeight = FontWeights.Bold;

}



private void CB_Click_1(object sender, RoutedEventArgs e)
{
Random r = new Random();
int a = r.Next(1, 100);
te.Content = a;

if (a<90)
{
if (t1 < 1000)
{
Money.Content = t1;
t1 = t1 + t1;
}
else
{
Money.FontSize = 50;
Money.Content = t1;
t1 = t1 + t1;
}
} else
{
t1 = 1;
Money.Content = t1;

}


}

private void Button_Click(object sender, RoutedEventArgs e)
{

balance = t1 / 2;
MonBalance.FontSize = 35; //saved balance
label name
MonBalance.Content = savedbalance +
balance;
Money.FontWeight = FontWeights.Bold;
savedbalance = balance;
t1 = 1;





}
}
}

Continue reading...
 
Back
Top