index > Visual C# General > Correct me!

Correct me!

Here my code and I need your help... This is a game about number guessing, computer generate a number, and the user try to find it...
Firstly;
The user choosing these 3 selection;
digits: 0-9 we do it by combobox;
chance: we do it with textbox...
Digits repeatable and nonrepatable(I NEED THIS);(with radio buttons)

And then;

The user write his guess in to theTEXTBOX... And we must compare this digit by digit. Because we will give a hint about the number, like "how many digit's place is true, and how many digits are existing in the number which one the user trying to found...

I hope U can understand something...


We must add the program user name, timer and score list...



Hey if u interest with my program add me:
peaceforce18@hotmail.com waiting for your help...

________________________________________________________________*

using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Oyun2006_2
{
    public partial class FletsGame : Form
    {
        public bool isRepeatable = false;
        public static int no_of_chances, no_of_digits, guess_left = 0;
        public static ArrayList dizibas = new ArrayList();

        public FletsGame()
        {
            InitializeComponent();
        }

        private void FletsGame_Load(object sender, EventArgs e)
        {
            groupBox2.Enabled = false;
        }

        private void cmbSelect_No_Of_Digits_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                no_of_digits = int.Parse(cmbSelect_No_Of_Digits.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("- " + ex.Message, "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void txtHow_many_chances_TextChanged(object sender, EventArgs e)
        {
            try
            {
                no_of_chances = int.Parse(txtHow_many_chances.Text);
                txt_Chances_Left.Text = no_of_chances.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("- " + ex.Message, "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void rd_True_CheckedChanged(object sender, EventArgs e)
        {
            isRepeatable = true;
        }

        private void rd_False_CheckedChanged(object sender, EventArgs e)
        {
            isRepeatable = false;
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            if (cmbSelect_No_Of_Digits.Text != "" && txtHow_many_chances.Text != "")
            {
                groupBox1.Visible = false;
                groupBox2.Enabled = true;
            }
            else
            {
                MessageBox.Show("- Enter all variables to start the game.", "Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void btnRandom_Numbe_Click(object sender, EventArgs e)
        {
            Random r = new Random();
            int bas1, bas2, bas3, bas4, bas5, bas6, bas7, bas8, bas9;
            bas9 = r.Next(1, 9); bas8 = r.Next(1, 9); bas7 = r.Next(1, 9);
            bas6 = r.Next(1, 9); bas5 = r.Next(1, 9); bas4 = r.Next(1, 9);
            bas3 = r.Next(1, 9); bas2 = r.Next(1, 9); bas1 = r.Next(1, 9);
            dizibas.Add(bas1);
            dizibas.Add(bas2);
            dizibas.Add(bas3);
            dizibas.Add(bas4);
            dizibas.Add(bas5);
            dizibas.Add(bas6);
            dizibas.Add(bas7);
            dizibas.Add(bas8);
            dizibas.Add(bas9);

            switch (no_of_digits)
            {
                case 9:
                    txtNumber.Text = bas1.ToString() + bas2.ToString() + bas3.ToString() + bas4.ToString() + bas5.ToString() + bas6.ToString() + bas7.ToString() + bas8.ToString() + bas9.ToString();
                    break;
                case 8:
                    txtNumber.Text = bas1.ToString() + bas2.ToString() + bas3.ToString() + bas4.ToString() + bas5.ToString() + bas6.ToString() + bas7.ToString() + bas8.ToString();
                    break;
                case 7:
                    txtNumber.Text = bas1.ToString() + bas2.ToString() + bas3.ToString() + bas4.ToString() + bas5.ToString() + bas6.ToString() + bas7.ToString();
                    break;
                case 6:
                    txtNumber.Text = bas1.ToString() + bas2.ToString() + bas3.ToString() + bas4.ToString() + bas5.ToString() + bas6.ToString();
                    break;
                case 5:
                    txtNumber.Text = bas1.ToString() + bas2.ToString() + bas3.ToString() + bas4.ToString() + bas5.ToString();
                    break;
                case 4:
                    txtNumber.Text = bas1.ToString() + bas2.ToString() + bas3.ToString() + bas4.ToString();
                    break;
                case 3:
                    txtNumber.Text = bas1.ToString() + bas2.ToString() + bas3.ToString();
                    break;
                case 2:
                    txtNumber.Text = bas1.ToString() + bas2.ToString();
                    break;
                case 1:
                    txtNumber.Text = bas1.ToString();
                    break;
            }
        }

        private void btnEnd_Application_Click(object sender, EventArgs e)
        {
            DialogResult answer = MessageBox.Show("Are you sure you want to exit?", "Confirm Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (answer == DialogResult.Yes)
            {
                Application.Exit();
            }
        }

        private void btnGuess_Click(object sender, EventArgs e)
        {
            guess_left = int.Parse(txt_Chances_Left.Text);
            guess_left = guess_left - 1;
            txt_Chances_Left.Text = guess_left.ToString();
            if (guess_left != 0)
            {
                txtPosition.Text = "";
                txtMatched.Text = "";

                string your_guess = txtYour_Guess.Text;
                string correct_number = txtNumber.Text;

                int count = 1;

                foreach (Char c in your_guess)
                {
                    StringBuilder sb = new StringBuilder();
                    sb = sb.Append(c);
                    Int32 num_check = Convert.ToInt32(sb.ToString());
                    foreach (Char diz in correct_number)
                    {
                        StringBuilder sb1 = new StringBuilder();
                        sb1 = sb1.Append(diz);
                        Int32 num_check1 = Convert.ToInt32(sb1.ToString());

                        if (num_check == num_check1)
                        {
                            txtMatched.AppendText(num_check.ToString());
                            txtPosition.AppendText(count.ToString());
                            count = count + 1;
                        }
                    }
                }
            }
            else
                groupBox2.Enabled = false;
        }
    }
}

_______________________________________________________________* 

thank u very much subissiso....
_______________________________________________________________*

Hey if u interest with my program add me:
peaceforce18@hotmail.com waiting for your help... Thank u very much.




Lacix Just A Different Way
Lacia
Why dont you help me_???


Lacix Just A Different Way
Lacia
Lacia wrote:
Why dont you help me_???


You have to be a little patient, so when someone can and know how to help you they will. At least I think everyone is here to help and to learn something from each other, so eventually someone is going to help you :)


I didn't understand what you want exactly:

- is there something wrong with the code?
n0n4m3
Lacia, is this a homework assignment? If it is, the shame on you! If it's not homework, then it would be very helpful for you to ask specific questions about your code. Which part of your code do you need help with? There a lots of people who will help you if you ask specific questions.



I love C# .NET
Kokyu

The user choosing these 3 selection;
digits: 0-9 we do it by combobox;
chance: we do it with textbox...
Digits repeatable and nonrepatable(I NEED THIS);(with radio buttons)

I need your help about non-repeatable digits generating...
For example;

the user selected 5 digits number and the non-repeatable radio button;

then our program must generate a number like that; 25364... There is no digits repeatable... if u checked the code u can understan clearly...

if the user selected repeatable radio button, our program can generate 42154... This number include two 4...

if u have any question about that, I'll try give an answer with my bad english...




Lacix Just A Different Way
Lacia
Hi,
if I understood you correctly, you want a number with 5 digits (if the user has chosen 5) and that this number has all digits different from each other. So check this code:

// create an array to track which digits were inserted
n0n4m3
reply 6

You can use google to search for other answers

 

More Articles

• Issue with COM Port Access (serial port emulation)
• Using a variable to select an array
• How can be possible to change the partial class name ?
• DataGridView.Rows.Add... problem!
• VWDWebCache in recycle bin
• how to block all internet acess
• Customizing FileDialog window
• datagridview
• GridView Control RowCommand
• Copy a table from ms sql to ms access
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• How to display Chinese Characters in a C
• Graphics question
• How to open help file in a windows appli
• Adding button to sidebar in Open dialog
• Shell Context menu (aka Win Explorer con
• POP Connection
• C# in 21 Days
• No of lines of code in any windows form
• Migration
• import file from a remote machine to loc
• Security exception unhandled when using
• Connect to database on server
• Controling windows Volume
• I need simple code editor component on w
• MDIChild Login Form

Hot Articles

• what is ADO.net??
• Video Files
• datasets -- hiding passwords from user's
• How Collections.HashTable does arrange i
• My code editor
• Picture + Text in One richTextBox
• how can i show a message if it wasn't us
• detecting close button of browser in C#
• Clear the Selection in DataGrid View in
• Serializing Derived Classes
• VSTO Reference
• WebBrowser control and Cookies
• Installation Support
• Disabling Cell navigation in datagrid
• BinaryFormatter Incompatability Exception

Recommend Articles

• BackgroundWorker Intelligent Drag drop C
• per page
• Download file(MP3) with progressbar
• Deleting IE Cache
• How to get the text inside an MS_WINTOPI
• Error Help please!
• Data Source Configuration Wizard in my app
• as to show tables of the data base throu
• monitoring registry and folders
• how to use cursor in c#
• Delete a directory and all its contents
• delete datagridviewrow
• please solve my problem
• form not repainting text
• source code for .NET classes