We want to give the Attendant the ability to rate their food based on if it's good or not. To do this we will set up a conditional that checks if the Food's IsGood boolean is either true or false.
To start we will define a method that only assigns a rating of 4 if the Food is good.
In English this would be, "Check if the IsGood field value is the same as true. If it is, give it a rating of 4."
So when we run the application, we can see that the conditional will evaluate to false because the IsGood field's value is false and a Rating will never be assigned.
In this case the IsGood field value is false because it has never been assigned to and the default value for bool types is false. So let's make someone give a review of the Food.
Now if we run the application again...
The conditional evaluates to true and the Rating field is assigned the value 4.
It is important to note, however, that the == is not actually necessary when checking a bool value. Conditionals only care about whether something is true or false and bool types already have that value assigned to them so using the == operator is redundant. Instead, conditionals checking bool values can be written as:
Since the IsGood field has a boolean value, all that needs to be checked is the value of that field.