AQA Pest2a Validate PlayerName Solution

preview_player
Показать описание
A quick solution showing you how to validate the playername
Рекомендации по теме
Комментарии
Автор

They may ask to change GetplayerName() function? In your solution if PlayerName is not set to "" in GetplayerName() function, will there be runtime error?

pxla
Автор

Hi,
GetPlayerName always returns a string. If any characters are entered by the player then that string will be returned . If nothing is entered then an empty sting "" will be returned. I can't see how a runtime error (type exception) could be thrown. 

You could validate within the GetPlayername function... I just felt it was clearer where I placed it.  

If you getting an error please feel free to reply and I'll help if I can

joemccarthyholland