Jump to content

Can't seem to find the issue

TheRedViper
Go to solution Solved by espurritado,

well this is going to be kind of obvious and probably you have checked it already but, have you checked it's the same spelling?

 

what happens if for scissors you use just an else instead of an else if?

Hello there, I made a windows form program in C that allows you and another player to pick either rock, paper or scissors and ''hide the selection'' from each other then determine a winner. The selection of the user choice is made through a combo box. When the user selects either paper, rock or scissors in the combobox, his player picturebox changes image for his selection. However, rock and paper works, but scissors doesnt and its weird because its the exact same code lines than the 2 others with only the name of the text changed. The code under is the code associated with the event ''SelectedValueChanged'' of the ComboBox.

 

private: System::Void cboChoix_SelectedValueChanged(System::Object^  sender, System::EventArgs^  e) {
					if(iTour == 0)
					{
						if(cboChoix->Text != "")
						{
							if(cboChoix->Text == "Rock")
							{
								iChoix1 = 1;
								picJoueur1->Visible = true;
								picJoueur1->Image = picRock->Image;
							}
							else if(cboChoix->Text == "Paper")
							{
								iChoix1 = 2;
								picJoueur1->Visible = true;
								picJoueur1->Image = picPaper->Image;
							}
							else if(cboChoix->Text == "Scissors")
							{
								iChoix1 = 3;
								picJoueur1->Visible = true;
								picJoueur1->Image = picScissors->Image;
							}
						}
					}
					else if(iTour == 1)
					{
						if(cboChoix->Text != "")
						{
							if(cboChoix->Text == "Rock")
							{
								iChoix2 = 1;
								picJoueur2->Visible = true;
								picJoueur2->Image = picRock->Image;
							}
							else if(cboChoix->Text == "Paper")
							{
								iChoix2 = 2;
								picJoueur2->Visible = true;
								picJoueur2->Image = picPaper->Image;
							}
							else if(cboChoix->Text == "Scissors")
							{
								iChoix2 = 3;
								picJoueur2->Visible = true;
								picJoueur2->Image = picScissors->Image;
							}
						}
					}
		 }

 

CPU: Intel Core i9-10900K  MOBO: ROG MAXIMUS XII FORMULA GPU: 2080ti Hall of Fame 10th anniversary limited edition  PSU: Asus ROG THOR 1200W  COOLER: Optimus foundation black acetal RADS: 3x EKWB CoolStream PE 360  LOOP: EKWB torque HDC fittings / EKWB ZMT 15,9/9,5mm / EKWB CryoFuel Clear MONITOR: Acer predator X34

Link to comment
Share on other sites

Link to post
Share on other sites

well this is going to be kind of obvious and probably you have checked it already but, have you checked it's the same spelling?

 

what happens if for scissors you use just an else instead of an else if?

The best way to measure the quality of a piece of code is "Oh F*** "s per line

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, espurritado said:

well this is going to be kind of obvious and probably you have checked it already but, have you checked it's the same spelling?

 

what happens if for scissors you use just an else instead of an else if?

I had already checked if the spelling was correct and I also tried changing both else if to simple if and it didnt work but changing the scissors one for else did work so thank you a lot sir.

CPU: Intel Core i9-10900K  MOBO: ROG MAXIMUS XII FORMULA GPU: 2080ti Hall of Fame 10th anniversary limited edition  PSU: Asus ROG THOR 1200W  COOLER: Optimus foundation black acetal RADS: 3x EKWB CoolStream PE 360  LOOP: EKWB torque HDC fittings / EKWB ZMT 15,9/9,5mm / EKWB CryoFuel Clear MONITOR: Acer predator X34

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×