예제 #1
0
        //Adds player to table
        public int add_Player(Player player)
        {
            Boolean found = false;
            int found_i = -1;

            //loops through the table for the first open spot
            for (int i = 0; i < 5; i++)
            {
                if (table[i] == null && found == false) // Spot found and inserts player into table at the current iterration
                {
                    table[i] = player;
                    found = true;
                    found_i = i;
                }
            }

            //Once the search for open spot is done, if a spot isn't found lets the user know the table is full
            if (found == false)
            {
                Console.WriteLine("Sorry " + player.get_Name() + ", this table is full.");
            }

            return found_i;
        }
예제 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            //create Blackjack table/cards
            gameTable1.create_Deck(1);
            gameTable1.shuffle_Deck();

            this.menuItem5.Enabled = true;
            this.button5.Visible = true;
            this.button6.Visible = true;
            this.button7.Visible = true;
            this.button8.Visible = true;
            this.button9.Visible = true;
            this.button11.Visible = true;

            this.button3.Visible = false;
            this.button4.Visible = false;

            this.richTextBox1.Visible = true;
            this.richTextBox2.Visible = true;

            if (tempName.ShowDialog() == DialogResult.OK)
            {
                MessageBox.Show("To start select the bet amount by clicking the Chips and then click Bet!");
                Player one = new Player(tempName.InputResult, 1);

                MainForm.gameTable1.add_Player(one);

                textBox1.Text = one.get_Name();
                textBox1.Visible = true;

                textBox2.Visible = true;
                textBox3.Visible = true;
                textBox4.Visible = true;
                textBox5.Visible = true;

                textBox1.TextAlign = ContentAlignment.MiddleCenter;
                textBox2.TextAlign = ContentAlignment.MiddleCenter;
                textBox3.TextAlign = ContentAlignment.MiddleCenter;
                textBox4.TextAlign = ContentAlignment.MiddleCenter;
                textBox5.TextAlign = ContentAlignment.MiddleCenter;
                textBox6.TextAlign = ContentAlignment.MiddleCenter;
            }

            this.pictureBox2.Enabled = true;
            this.pictureBox3.Enabled = true;
            this.pictureBox4.Enabled = true;
            this.pictureBox5.Enabled = true;
        }
예제 #3
0
 public void remove_Player(Player player)
 {
     Boolean found_Player = false;
     //scans the table for a specific player
     for (int i = 0; i < 5; i++)
     {
         if (table[i] != null) //checks first is spot is not empty, if not then moves the next spot
         {
             //here the player is found and removes player
             if (table[i].get_Name() == player.get_Name())
             {
                 table[i] = null;
                 found_Player = true;
             }
         }
     }
     //Output is player is not found
     if (!found_Player) { Console.WriteLine(player.get_Name() + " was not found in the table."); }
 }