Beginner Scripting: IF Statements

 


This weeks Coding task was short but interesting. The analogy about the coffee made me laugh and also made me realise it was in fact time for a coffee myself. This task was about using the IF and ELSE correctly in coding and also using the ELSE IF statement correctly. Below is the code used in the video along with the Debug.Log showing how the code works.


void TemperatureTest () { // If the coffee's temperature is greater than the hottest drinking temperature... if(coffeeTemperature > hotLimitTemperature) { // ... do this. print("Coffee is too hot."); } // If it isn't, but the coffee temperature is less than the coldest drinking temperature... else if(coffeeTemperature < coldLimitTemperature) { // ... do this. print("Coffee is too cold."); } // If it is neither of those then... else { // ... do this. print("Coffee is just right."); } }

Comments

Popular Posts