Exemplo n.º 1
0
        private void SetupdograceTrack()
        {
            Dogs.StartingPosition1   = Dog1.Right - dogracetrack.Left;
            Dogs.dogracetrackLength1 = dogracetrack.Size.Width - 70;  //fixing length of dograce - till finish line

            Dogss[0] = new Dogs()
            {
                DogsPictureBox = Dog1
            };
            Dogss[1] = new Dogs()
            {
                DogsPictureBox = Dog2
            };
            Dogss[2] = new Dogs()
            {
                DogsPictureBox = Dog3
            };
            Dogss[3] = new Dogs()
            {
                DogsPictureBox = Dog4
            };

            DogRacers[0] = pFactory.getDogRacer("Kom", MaximumBet, KomBet);     //getting Kom object from factory class
            DogRacers[1] = pFactory.getDogRacer("Marry", MaximumBet, MarryBet); //getting Marry object from factory class
            DogRacers[2] = pFactory.getDogRacer("Bob", MaximumBet, BobBet);     //getting Bob object from factory class


            foreach (DogRacer DogRacer in DogRacers)
            {
                DogRacer.UpdateLabels();
            }
        }
Exemplo n.º 2
0
        private void dograce_Click(object sender, EventArgs e)
        {
            bool NoWinner = true;
            int  winningDogs;

            dograce.Enabled = false; //disable start dograce button

            while (NoWinner)         // loop until we have a winner
            {
                Application.DoEvents();
                for (int i = 0; i < Dogss.Length; i++)
                {
                    if (Dogs.Run(Dogss[i]))
                    {
                        winningDogs = i + 1;
                        NoWinner    = false;
                        MessageBox.Show("winner of the dograce is - Dogs #" + winningDogs);
                        foreach (DogRacer DogRacer in DogRacers)
                        {
                            if (DogRacer.bet != null)
                            {
                                DogRacer.Collect(winningDogs); //give double amount to all who've won or deduce betted amount
                                DogRacer.bet = null;
                                DogRacer.UpdateLabels();
                            }
                        }
                        foreach (Dogs Dogs in Dogss)
                        {
                            Dogs.TakeStartingPosition();
                        }
                        break;
                    }
                }
            }
            if (DogRacers[0].busted && DogRacers[1].busted && DogRacers[2].busted)   //stop DogRacers from betting if they run out of cash
            {
                String            message = "Do you want to Play Again?";
                String            title   = "GAME OVER!";
                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult      result  = MessageBox.Show(message, title, buttons);
                if (result == DialogResult.Yes)
                {
                    SetupdograceTrack(); //restart game
                }
                else
                {
                    this.Close();
                }
            }
            dograce.Enabled = true; //enable dograce button
        }
Exemplo n.º 3
0
 public Bet(int Amount, int dogNum, DogRacer Bettor)
 {
     this.Amount = Amount;
     this.dogNum = dogNum;
     this.Bettor = Bettor;
 }