Pārlūkot izejas kodu

Add hints to exercises without starter implementation (#1084)

* Add hints to exercises without starter implementation

As exercises with difficulty 5 are the first exercises without starter
implementation, they should have a hints file explaining how to fix the
compiler errors that occur when an exercise doesn't have any starter
implementation.

This should be detailed in the policies doc.

* flatten-array: regenerate README

Also update description for how to generate readme as it was lacking
detail.
FridaTveit 8 gadus atpakaļ
vecāks
revīzija
69e8ba1363

+ 1
- 1
CONTRIBUTING.md Parādīt failu

171
 
171
 
172
   2. Clone [the problem-specifications repository](https://github.com/exercism/problem-specifications).
172
   2. Clone [the problem-specifications repository](https://github.com/exercism/problem-specifications).
173
 
173
 
174
-  3. Run `configlet generate . --only name_of_new_exercise` from the root of this repository.
174
+  3. Run `configlet generate . --only name_of_new_exercise --spec-path path_to_problem_specifications` from the root of this repository.
175
 
175
 
176
 * Check if there is canonical data for the exercise you're adding.
176
 * Check if there is canonical data for the exercise you're adding.
177
 This can be found at `https://github.com/exercism/problem-specifications/tree/master/exercises/EXERCISE-SLUG/canonical-data.json`.
177
 This can be found at `https://github.com/exercism/problem-specifications/tree/master/exercises/EXERCISE-SLUG/canonical-data.json`.

+ 13
- 1
POLICIES.md Parādīt failu

17
 
17
 
18
 | Track Event | Policies to review |
18
 | Track Event | Policies to review |
19
 |:------------|:-----------------|
19
 |:------------|:-----------------|
20
-| Exercise added/updated | [Prefer instance methods](#prefer-instance-methods); [Avoid using final](#avoid-using-final); [Adhere to best practices](#adhere-to-best-practices); [Starter implementations](#starter-implementations); [Ignore noninitial tests](#ignore-noninitial-tests); [Multiple file submissions](#multiple-file-submissions); [Name test class after class under test](#name-test-class-after-class-under-test)
20
+| Exercise added/updated | [Prefer instance methods](#prefer-instance-methods); [Avoid using final](#avoid-using-final); [Adhere to best practices](#adhere-to-best-practices); [Starter implementations](#starter-implementations); [Ignore noninitial tests](#ignore-noninitial-tests); [Multiple file submissions](#multiple-file-submissions); [Name test class after class under test](#name-test-class-after-class-under-test); [Add hint for the first exercises without starter implementation](#add-hint-for-the-first-exercises-without-starter-implementation)
21
 | Track rearranged | [Starter implementations](#starter-implementations); [Multiple file submissions](#multiple-file-submissions) |
21
 | Track rearranged | [Starter implementations](#starter-implementations); [Multiple file submissions](#multiple-file-submissions) |
22
 | New issue observed in track | [Good first patches](#good-first-patches) |
22
 | New issue observed in track | [Good first patches](#good-first-patches) |
23
 | "Good first patch" issue completed | [Good first patches](#good-first-patches) |
23
 | "Good first patch" issue completed | [Good first patches](#good-first-patches) |
79
 > The exception to this is if the tests are split into several test classes where each test class tests different functionality. In that case each class should be named `SomeClassNameFunctionalityTest` where `Functionality` is the name of the functionality to be tested in that class. See the [clock exercise](https://github.com/exercism/java/tree/master/exercises/clock) as an example.
79
 > The exception to this is if the tests are split into several test classes where each test class tests different functionality. In that case each class should be named `SomeClassNameFunctionalityTest` where `Functionality` is the name of the functionality to be tested in that class. See the [clock exercise](https://github.com/exercism/java/tree/master/exercises/clock) as an example.
80
 
80
 
81
 References: [[1](https://github.com/exercism/java/issues/697)]
81
 References: [[1](https://github.com/exercism/java/issues/697)]
82
+
83
+### Add hint for the first exercises without starter implementation
84
+
85
+> According to the starter implementation policy, any exercise with difficulty 4 or lower should have starter implementation.
86
+> Any exercise with difficulty 5 or above will have no starter implementation (unless its signature is very complicated).
87
+> This could be confusing to users when tackling their first exercise with difficulty 5 when they are used to starter implementation being provided.
88
+
89
+> Therefore a hints.md file should be added to the .meta directory for every exercise with difficulty 5.
90
+> This file should explain what they need to do when there is no starter implementation.
91
+> The files should all be the same so you can copy it from any other exercise with difficulty 5, e.g. [flatten-array](https://github.com/exercism/java/tree/master/exercises/flatten-array/.meta/hints.md).
92
+
93
+> We add the file to every exercise with difficulty 5 because the structure of the track means that we don't know which exercise will be the first one without starter implementation that a user will be faced with.

+ 58
- 0
exercises/flatten-array/.meta/hints.md Parādīt failu

1
+Since this exercise has difficulty 5 it doesn't come with any starter implementation.
2
+This is so that you get to practice creating classes and methods which is an important part of programming in Java.
3
+It does mean that when you first try to run the tests, they won't compile.
4
+They will give you an error similar to:
5
+```
6
+ path-to-exercism-dir\exercism\java\name-of-exercise\src\test\java\ExerciseClassNameTest.java:14: error: cannot find symbol
7
+        ExerciseClassName exerciseClassName = new ExerciseClassName();
8
+        ^
9
+ symbol:   class ExerciseClassName
10
+ location: class ExerciseClassNameTest
11
+```
12
+This error occurs because the test refers to a class that hasn't been created yet (`ExerciseClassName`).
13
+To resolve the error you need to add a file matching the class name in the error to the `src/main/java` directory.
14
+For example, for the error above you would add a file called `ExerciseClassName.java`.
15
+
16
+When you try to run the tests again you will get slightly different errors.
17
+You might get an error similar to:
18
+```
19
+  constructor ExerciseClassName in class ExerciseClassName cannot be applied to given types;
20
+        ExerciseClassName exerciseClassName = new ExerciseClassName("some argument");
21
+                                              ^
22
+  required: no arguments
23
+  found: String
24
+  reason: actual and formal argument lists differ in length
25
+```
26
+This error means that you need to add a [constructor](https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html) to your new class.
27
+If you don't add a constructor, Java will add a default one for you.
28
+This default constructor takes no arguments.
29
+So if the tests expect your class to have a constructor which takes arguments, then you need to create this constructor yourself.
30
+In the example above you could add:
31
+```
32
+ExerciseClassName(String input) {
33
+
34
+}
35
+``` 
36
+That should make the error go away, though you might need to add some more code to your constructor to make the test pass!
37
+
38
+You might also get an error similar to:
39
+```
40
+  error: cannot find symbol
41
+        assertEquals(expectedOutput, exerciseClassName.someMethod());
42
+                                                       ^
43
+  symbol:   method someMethod()
44
+  location: variable exerciseClassName of type ExerciseClassName
45
+```
46
+This error means that you need to add a method called `someMethod` to your new class.
47
+In the example above you would add:
48
+```
49
+String someMethod() {
50
+  return "";
51
+}
52
+```
53
+Make sure the return type matches what the test is expecting.
54
+You can find out which return type it should have by looking at the type of object it's being compared to in the tests.
55
+Or you could set your method to return some random type (e.g. `void`), and run the tests again.
56
+The new error should tell you which type it's expecting.
57
+
58
+After having resolved these errors you should be ready to start making the tests pass!

+ 62
- 0
exercises/flatten-array/README.md Parādīt failu

10
 
10
 
11
 output: [1,2,3,4,5]
11
 output: [1,2,3,4,5]
12
 
12
 
13
+# Java Tips
14
+
15
+Since this exercise has difficulty 5 it doesn't come with any starter implementation.
16
+This is so that you get to practice creating classes and methods which is an important part of programming in Java.
17
+It does mean that when you first try to run the tests, they won't compile.
18
+They will give you an error similar to:
19
+```
20
+ path-to-exercism-dir\exercism\java\name-of-exercise\src\test\java\ExerciseClassNameTest.java:14: error: cannot find symbol
21
+        ExerciseClassName exerciseClassName = new ExerciseClassName();
22
+        ^
23
+ symbol:   class ExerciseClassName
24
+ location: class ExerciseClassNameTest
25
+```
26
+This error occurs because the test refers to a class that hasn't been created yet (`ExerciseClassName`).
27
+To resolve the error you need to add a file matching the class name in the error to the `src/main/java` directory.
28
+For example, for the error above you would add a file called `ExerciseClassName.java`.
29
+
30
+When you try to run the tests again you will get slightly different errors.
31
+You might get an error similar to:
32
+```
33
+  constructor ExerciseClassName in class ExerciseClassName cannot be applied to given types;
34
+        ExerciseClassName exerciseClassName = new ExerciseClassName("some argument");
35
+                                              ^
36
+  required: no arguments
37
+  found: String
38
+  reason: actual and formal argument lists differ in length
39
+```
40
+This error means that you need to add a [constructor](https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html) to your new class.
41
+If you don't add a constructor, Java will add a default one for you.
42
+This default constructor takes no arguments.
43
+So if the tests expect your class to have a constructor which takes arguments, then you need to create this constructor yourself.
44
+In the example above you could add:
45
+```
46
+ExerciseClassName(String input) {
47
+
48
+}
49
+``` 
50
+That should make the error go away, though you might need to add some more code to your constructor to make the test pass!
51
+
52
+You might also get an error similar to:
53
+```
54
+  error: cannot find symbol
55
+        assertEquals(expectedOutput, exerciseClassName.someMethod());
56
+                                                       ^
57
+  symbol:   method someMethod()
58
+  location: variable exerciseClassName of type ExerciseClassName
59
+```
60
+This error means that you need to add a method called `someMethod` to your new class.
61
+In the example above you would add:
62
+```
63
+String someMethod() {
64
+  return "";
65
+}
66
+```
67
+Make sure the return type matches what the test is expecting.
68
+You can find out which return type it should have by looking at the type of object it's being compared to in the tests.
69
+Or you could set your method to return some random type (e.g. `void`), and run the tests again.
70
+The new error should tell you which type it's expecting.
71
+
72
+After having resolved these errors you should be ready to start making the tests pass!
73
+
74
+
13
 # Running the tests
75
 # Running the tests
14
 
76
 
15
 You can run all the tests for an exercise by entering
77
 You can run all the tests for an exercise by entering