티스토리 뷰
///Start 10.50 14/11/2017
///End 11.40 14/11/2017
///To see the ideal result of gambling in ideal conditon.
///Start 10.50 14/11/2017
///End 11.40 14/11/2017
///To see the ideal result of gambling in ideal conditon.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CrownPerthCasino
{
public partial class FormMain : Form
{
int HorT = 0; //It was Head or tail. But for accuracy, i increased to 1 to 10000.
int BudgetValue = 0; //Value of Budget.
int BettingValue = 0; //Value of Betting amount.
int Win = 0, Lose = 0,Total=0; //Count number of game that win, lose and total.
public FormMain()
{
InitializeComponent();
}
private void btnHead_Click(object sender, EventArgs e) //Player bet to Head
{
CoinFlip(); //Flip the coin every time the butten is pressed
if (HorT <= 5000) //If the random value is less than 5000, Player wins.
{
BudgetValue += BettingValue; //Gain the money.
Win += 1; //Count the win game.
}
else //If the random value is more than 5000, Player loses.
{
BudgetValue -= BettingValue; //Lose the money.
Lose += 1; //Count the lose game.
}
ShowResult(); //Show result after process.
} //End of btnHead_Click
private void btnTail_Click(object sender, EventArgs e) //Player bet to Tail
{
CoinFlip(); //Flip the coin every time the butten is pressed
if (HorT >= 5001) //If the random value is more than 5000, Player wins.
{
BudgetValue += BettingValue; //Gain the money.
Win += 1; //Count the win game.
}
else //If the random value is less than 5000, Player loses.
{
BudgetValue -= BettingValue; //Lose the money.
Lose += 1; //Count the lose game.
}
ShowResult(); //Show result after process.
} //End of btnTail_Click
private void tbHead10_Click(object sender, EventArgs e) //Player bet to Head 10 times.
{
for (int i = 0; i < 10; i++) //Run for 10 times
{
btnHead_Click(sender, e); //Call btnHead_Click method.
}
} //End of tbHead10_Click
private void tbTail10_Click(object sender, EventArgs e) //Player bet to Tail 10 times.
{
for (int i = 0; i < 10; i++) //Run for 10 times
{
btnTail_Click(sender, e); //Call btnTail_Click method.
}
} //End of tbTail10_Click
private void tbHead100_Click(object sender, EventArgs e) //Player bet to Head 100 times.
{
for (int i = 0; i < 100; i++) //Run for 100 times
{
btnHead_Click(sender, e); //Call btnHead_Click method.
}
} //End of tbHead100_Click
private void tbTail100_Click(object sender, EventArgs e) //Player bet to Tail 100 times.
{
for (int i = 0; i < 100; i++) //Run for 100 times
{
btnTail_Click(sender, e); //Call btnTail_Click method.
}
} //End of tbTail100_Click
private void tbHead10000_Click(object sender, EventArgs e) //Player bet to Head 10000 times
{
for (int i = 0; i < 10000; i++) //Run for 10000 times
{
btnHead_Click(sender, e); //Call btnHead_Click method.
}
} //End of tbHead10000_Click
private void lblBudget_Click(object sender, EventArgs e) //To reset entire value.
{
HorT = 0; //Reset to 0.
BudgetValue = 0; //Reset to 0.
BettingValue = 0; //Reset to 0.
Win = 0; Lose = 0; Total = 0; //Reset to 0.
tbResult.Text = "0"; //Reset to 0.
ShowResult(); //Show the result after reset.
} //End of lblBudget_Click
private void CoinFlip() //Actual coin flip process
{
Random rand = new Random(); //Create a random vatiable.
HorT = rand.Next(1, 10001); //Put random number between 1 to 10000.
tbResult.Text = HorT.ToString(); //Display the random value to textbox.
Total += 1; //Count total game played.
BudgetValue = int.Parse(tbBudget.Text);
BettingValue = int.Parse(tbBetting.Text);
} //End of CoinFlip
private void ShowResult() //Display the result to textbox.
{
tbBudget.Text = BudgetValue.ToString(); //Display Budget.
tbWinCount.Text = Win.ToString(); //Display number of win games.
tbLoseCount.Text = Lose.ToString(); //Display number of lose games.
tbTotalGame.Text = Total.ToString(); //Display number of total games.
tbDifference.Text = (Win - Lose).ToString(); //Display number of games difference between win and lose.
Application.DoEvents(); //To make it more pricise.
} //End of ShowResult
}
}Idle / In progress of Head x10000 / Result of Head x10000
'IT' 카테고리의 다른 글
| How to browse faster than using bookmark (0) | 2018.01.04 |
|---|---|
| RAID (0) | 2017.11.16 |
| USB name and icon in windows (0) | 2017.11.12 |
| every30min_AppDev (0) | 2017.10.31 |
| 블로그 코드 작성법 (0) | 2017.10.22 |
댓글