You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are three overloaded Describe() methods which each take a single parameter (character, destination and travel method. They are not addressed by this issue.
In addition to the above 3 overloads the instructions require that the code should allow:
the caller to specify all 3 aspects in one call (character + destination + travel method).
or the caller to specify just 2 aspects, character and destination, in which case TravelMethod.Walking should be used as the travel method.
There are 2 ways for the student to approach this. Firstly, to include one overload with 3 parameters and a separate one with 2 parameters. In fact the boilerplate takes this approach.
The alternative is to omit the 2 parameter method altogether and give the final (TravelMethod) parameter of the 3 parameter method a default value of TravelMethod.Walking as is shown in the example code.
The analyzer should report that the second approach, giving the parameter a default value, is preferable. This should also handle the case where named parameters are used.
The text was updated successfully, but these errors were encountered:
See the method-overloading exercise.
The following feature should be added:
There are three overloaded
Describe()
methods which each take a single parameter (character, destination and travel method. They are not addressed by this issue.In addition to the above 3 overloads the instructions require that the code should allow:
the caller to specify all 3 aspects in one call (character + destination + travel method).
or the caller to specify just 2 aspects, character and destination, in which case
TravelMethod.Walking
should be used as the travel method.There are 2 ways for the student to approach this. Firstly, to include one overload with 3 parameters and a separate one with 2 parameters. In fact the boilerplate takes this approach.
The alternative is to omit the 2 parameter method altogether and give the final (
TravelMethod
) parameter of the 3 parameter method a default value ofTravelMethod.Walking
as is shown in the example code.The analyzer should report that the second approach, giving the parameter a default value, is preferable. This should also handle the case where named parameters are used.
The text was updated successfully, but these errors were encountered: