소스 검색

Merge pull request #1239 from c-thornton/bracket-push

bracket-push: added hints about no starter implementation
Sam Warner 8 년 전
부모
커밋
7e3bcf911f
No account linked to committer's email
2개의 변경된 파일120개의 추가작업 그리고 0개의 파일을 삭제
  1. 58
    0
      exercises/bracket-push/.meta/hints.md
  2. 62
    0
      exercises/bracket-push/README.md

+ 58
- 0
exercises/bracket-push/.meta/hints.md 파일 보기

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/bracket-push/README.md 파일 보기

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