Posts

Showing posts from March 31, 2018

Code Explained: ButtonCheckScore - Task 1 Part 2

Image
This code checks the score inputted in the text field and displays the colour of the medal that the user would have won depending on the score.  This is an explanation of the code used for this task: The public variables m_colours as the type 'colour', m_inputfield as the type 'input field', m_medalImage as the type 'image', m_mediaText as the type 'text' are declared. The function GetScoreandSetMedal() has no parameters and uses a try catch statement which are used to handle exceptions. The integer variable 'value' is declared. The try block is where exceptions occur and therefore handles what happens when an unvalid input such as a letter is inputted into the text field. The try block uses int.parse to convert the text string inputted into the input field into an integer which is set in the integer variable 'value'. However if a random letter is inputted instead, then the statement catches this exception and therefore sets