CheckIfUserInputEvaluationIsATarget Flashcards

(4 cards)

1
Q

How does the program evaluate the user expression, from checking whether it is a valid expression and how it handles incorrect expressions?

A

Converts the user’s expression in RPN to an integer or returns -1 if the result was non-integer.

int UserInputEvaluation=EvaluateRPN(UserInputInRPN);

bool UserInputEvaluationIsATarget = false;
returns false if the users input doesn’t evaluate to a target.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does the program remove a target if the users expression matches a target?

A

Loops through all targets. If the result matches a target, awards +2 to Score, sets that target to -1 (marking it cleared), and sets the boolean to true.

for (int Count = 0; Count < Targets.Count; Count++)
{
if (Targets[Count] == UserInputEvaluation)
{
Score += 2;
Targets[Count] = -1; // mark target as cleared.
UserInputEvaluationIsATarget = true;
Set a boolean so we know we hit at least one target.
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is returned when the user successfully hits a target at the end of this function?

A

Tells the caller whether the user successfully hit a target.Set a boolean so we know we hit at least one target.Return whether at least one match was found.

return UserInputEvaluationIsATarget;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the main function of this program?

A

decides if a user’s expression has “cleared” any targets. Called every turn from PlayGame.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly