Implementation of the second from the book Head First C#