Clover

Clover

  • NA
  • 2
  • 1.7k

HELP! Make my program choose 4 random colors from a list

Jul 30 2014 10:27 PM
SORRY FOR THE LONG POST BUT PLS TRY TO READ :)

Okay. So Im a programming newbie. Ive only begun to learn C# for a month.
So bear with my limited knowledge. :D

Anyway... I want my program to pick 4 random colors (from a list of colors that I made) everytime I start the program.

I already did the list. I just dont know how I can make it pick 4 random colors from the list..
And not only that. I want that the 4 random colors, would be associated with those 4 buttons shown there in the picture.


Ill just explain the program if it helps.
Everytime the program starts, it will generate 4 random colors. (it will not be shown)
The User will then guess what those 4 colors are by clicking the buttons (the button changes its backcolor everytime the user clicks it). The user will have to click the check button in every try he makes.

Its like a mastermind-ish game (for those of you who knows what that game is).

What Ive done so far...

(These are for the buttons)

        private void Form1_Load(object sender, EventArgs e)
        {
            Color[] MMColors = {Color.Red, Color.Green, Color.Blue, Color.Yellow,Color.Orange,Color.DeepPink};

            button1.Tag = -1;
            button2.Tag = -1;
            button3.Tag = -1;
            button4.Tag = -1;

            Color[] GuessColors = {Color.Red, Color.Green, Color.Blue, Color.Yellow,Color.Orange,Color.DeepPink};
                   }        

        void CycleColor(Button button)
        {
            int ButtonColor = (int)button.Tag;
            if (ButtonColor == 5)
                ButtonColor = -1;
            ButtonColor = ButtonColor + 1;
            button.BackColor = MMColors[ButtonColor];
            button.Tag = ButtonColor;
        }

And for each button....
        private void button1_Click(object sender, EventArgs e)
        {
            CycleColor(button1);
        }



and just FYI. This is a class activity.. So I cant really change the rules or codes or anything here..

I know there are better ways to do this but
IT HAS TO BE MADE LIKE THIS.. 

So.. How can I finish the program? HELP pls?

Im seriously stuck. 

Answers (1)