Raycast Compare Tag

Lets say I have 5 question Game Objects and 4 Answer Game Objects. 4 answer game object have their own Tag assigned. If the user click the 1st question game object and the user need to select the correct game object. I achieved this using raycast.hit. Since each answer game object have a tag, I simply checked it and if it is true, User has selected the correct answer.

Problem:
What if the user select the wrong answer for the question? I do understand, I need to know how to solve this problem, User need to select the question and then need to click any one of the answer and if the selected answer tag is incorrect, Something will happen. How to compare this?

Example:

					if(hit.transform.tag == "Three" && S_Ans[0]) // User has selected 1st answer
					{
						Debug.Log("ClickedRight answer 3!");    					
					}

Any inputs will be appreciated. Thanks.

I would use a more OOP approach. You should have a question object and an answer object. The question object contains a reference to the answer object that is passed to it.

public class Question:MonoBehaviour{
    [SerializeField]private Answer correctAnswer = null;
    
    public bool OnAction(Answer givenAnswer){
         return givenAnswer == correctAnswer;
    }
}

public class Answer:MonoBehaviour{
     [SerializeField] private Question relatedQuestion = null;
     public void OnClickOfSomeKind(){
             bool result = relatedQuestion(this);
             // Pass result to some manager
     }
    // Data about answer
}

Your question object contains a reference to the right answer that you may pass via inspector or a method of your own. When you click the answer object, it asks the question object it is related to, if the answer is right. Actually, the answer does not know if it is right or not, this allows to reuse it easily without alteration. The question knows which is the right answer but does not know what answers are available, same reusability.

Once you called the OnClick method on the answer, you would pass the result to some manager of yours to trigger a specific action (success/failure).