exercism / exercism/csharp-analyzer
Add feature for method overloading exercise
- Dominant language
- C#
- Stars
- 16
- Forks
- 8
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 4
Description
See the [method-overloading exercise](https://github.com/exercism/v3/blob/master/languages/csharp/exercises/concept/method-overloading/.meta/design.md).
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](https://github.com/exercism/v3/blob/master/languages/csharp/exercises/concept/method-overloading/MethodOverloading.cs) takes this approach.
```csharp
public static string Describe(Character character, Destination destination, TravelMethod travelMethod) {}
public static string Describe(Character character, Destination destination) {}
```
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](https://github.com/exercism/v3/blob/master/languages/csharp/exercises/concept/method-overloading/.meta/Example.cs) code.
```csharp
public static string Describe(Character character, Destination destination, TravelMethod travelMethod = TravelMethod.Walking) {}
```
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.