java icon indicating copy to clipboard operation
java copied to clipboard

darts: Unnecessary complication of exercise by using method without parameters

Open JanB1 opened this issue 3 years ago • 3 comments

The exercise "Darts" is categorised in the "Conditionals If" exercises and is categorised as "easy".

While the exercise itself is indeed easy, the use of a 'score' method without parameters and thus the necessity to write a constructor is making the exercise more complicated to understand than it needs to be.

Especially as other, similar exercises just expect the student to write a method that uses parameters given.

Is there a reason why this simple exercise uses an approach that differs from this?

JanB1 avatar Jul 18 '22 14:07 JanB1

I agree we should simplify this.

So the task here is to have the exercise just require static methods instead of requiring the building of a new object and putting a method on it. Anyone is welcome to open a PR with this change.

andrerfcsantos avatar Jul 30 '22 10:07 andrerfcsantos

I think a different approach would be to instead let the user write a method that calculates the score using methods where the x and y position is passed as an argument, instead of pulling it from the object as a field.

The object creation and call of the methods with the proper arguments would more or less stay the same.

See the bird watcher tests for example.

JanB1 avatar Jul 30 '22 12:07 JanB1

@JanB1 I see, that works too :)

andrerfcsantos avatar Jul 30 '22 14:07 andrerfcsantos

is anyone working on this issue actively?

jennylia avatar Oct 14 '22 23:10 jennylia

@jennylia I don't think so, feel free to take this.

andrerfcsantos avatar Oct 15 '22 09:10 andrerfcsantos

yea I'll give it a try.

jennylia avatar Oct 17 '22 00:10 jennylia

https://github.com/exercism/java/pull/2180/files is my PR. Please also tag me for hacktoberfest thank you very much

jennylia avatar Oct 17 '22 00:10 jennylia

@andrerfcsantos

This issue should be closed.

kerolloz avatar Oct 19 '22 15:10 kerolloz

@kerolloz Indeed, thanks for the reminder.

andrerfcsantos avatar Oct 19 '22 19:10 andrerfcsantos