質問編集履歴

3

修正

2020/06/04 08:09

投稿

junnnnchan
junnnnchan

スコア26

test CHANGED
File without changes
test CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  public class Country {
4
4
 
5
- public class Country {
6
-
7
5
  String name;
8
6
 
9
7
  int gold = 0;
@@ -20,9 +18,9 @@
20
18
 
21
19
  }
22
20
 
23
- public void getName() {
21
+ public String getName() {
24
-
22
+
25
- this.name = name;
23
+ return name;
26
24
 
27
25
  }
28
26
 
@@ -48,6 +46,8 @@
48
46
 
49
47
  }
50
48
 
49
+
50
+
51
51
  ```
52
52
 
53
53
  ```
@@ -418,36 +418,24 @@
418
418
 
419
419
  Testsuite: medals3.AllTests
420
420
 
421
- Tests run: 4, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.025 sec
421
+ Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.026 sec
422
-
423
-
424
-
422
+
423
+
424
+
425
- Testcase: testAdd took 0.007 sec
425
+ Testcase: testAdd took 0.008 sec
426
-
426
+
427
- Testcase: testToString took 0.002 sec
427
+ Testcase: testToString took 0.003 sec
428
-
428
+
429
- Testcase: testGetName took 0.001 sec
429
+ Testcase: testGetName took 0 sec
430
+
431
+ Testcase: testCountry took 0.002 sec
430
432
 
431
433
  FAILED
432
434
 
433
- medals3.CountryクラスのgetNameメソッドがString型でない expected:<class java.lang.String> but was:<void>
434
-
435
- junit.framework.AssertionFailedError: medals3.CountryクラスのgetNameメソッドがString型でない expected:<class java.lang.String> but was:<void>
436
-
437
- at medals3.CountryTest.invokeStringMethod(CountryTest.java:156)
438
-
439
- at medals3.CountryTest.testGetName(CountryTest.java:175)
440
-
441
-
442
-
443
- Testcase: testCountry took 0 sec
444
-
445
- FAILED
446
-
447
435
  medals3.Countryクラスに不必要なメンバ変数: [sum] expected:<0> but was:<1>
448
436
 
449
437
  junit.framework.AssertionFailedError: medals3.Countryクラスに不必要なメンバ変数: [sum] expected:<0> but was:<1>
450
438
 
451
- at medals3.CountryTest.testCountry(CountryTest.java:
439
+ at medals3.CountryTest.testCountry(CountryTest.java:84)
452
440
 
453
441
  何が違うのかお願いします。

2

修正

2020/06/04 08:09

投稿

junnnnchan
junnnnchan

スコア26

test CHANGED
File without changes
test CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  public class Country {
4
4
 
5
+ public class Country {
6
+
5
7
  String name;
6
8
 
7
9
  int gold = 0;
@@ -32,13 +34,13 @@
32
34
 
33
35
  if(color == Color.Bronze) bronze++;
34
36
 
35
- sum = gold + silver + bronze;
37
+ sum = gold + silver + bronze;
36
38
 
37
39
  }
38
40
 
39
- public void toString() {
41
+ public String toString() {
40
-
42
+
41
- System.out.println(this.name + "(" + gold + "," + silver + "," + bronze + ")" + "[" + sum + "]");
43
+ return (this.name + "(" + gold + "," + silver + "," + bronze + ")" + "[" + sum + "]");
42
44
 
43
45
 
44
46
 
@@ -46,8 +48,6 @@
46
48
 
47
49
  }
48
50
 
49
-
50
-
51
51
  ```
52
52
 
53
53
  ```
@@ -398,10 +398,6 @@
398
398
 
399
399
  ```
400
400
 
401
- country class のpublic void tostring のvoidがエラーになっています。
402
-
403
- エラーの原因をご教示お願いします。
404
-
405
401
  country classでしたいこと
406
402
 
407
403
  <add method>
@@ -415,3 +411,43 @@
415
411
  です。
416
412
 
417
413
  よろしくお願いします。
414
+
415
+
416
+
417
+ エラー文
418
+
419
+ Testsuite: medals3.AllTests
420
+
421
+ Tests run: 4, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.025 sec
422
+
423
+
424
+
425
+ Testcase: testAdd took 0.007 sec
426
+
427
+ Testcase: testToString took 0.002 sec
428
+
429
+ Testcase: testGetName took 0.001 sec
430
+
431
+ FAILED
432
+
433
+ medals3.CountryクラスのgetNameメソッドがString型でない expected:<class java.lang.String> but was:<void>
434
+
435
+ junit.framework.AssertionFailedError: medals3.CountryクラスのgetNameメソッドがString型でない expected:<class java.lang.String> but was:<void>
436
+
437
+ at medals3.CountryTest.invokeStringMethod(CountryTest.java:156)
438
+
439
+ at medals3.CountryTest.testGetName(CountryTest.java:175)
440
+
441
+
442
+
443
+ Testcase: testCountry took 0 sec
444
+
445
+ FAILED
446
+
447
+ medals3.Countryクラスに不必要なメンバ変数: [sum] expected:<0> but was:<1>
448
+
449
+ junit.framework.AssertionFailedError: medals3.Countryクラスに不必要なメンバ変数: [sum] expected:<0> but was:<1>
450
+
451
+ at medals3.CountryTest.testCountry(CountryTest.java:
452
+
453
+ 何が違うのかお願いします。

1

修正

2020/06/04 07:54

投稿

junnnnchan
junnnnchan

スコア26

test CHANGED
File without changes
test CHANGED
@@ -260,6 +260,8 @@
260
260
 
261
261
  ``````
262
262
 
263
+ ```
264
+
263
265
  public class Competition {
264
266
 
265
267
  public static void main(String[] args) {
@@ -394,8 +396,6 @@
394
396
 
395
397
  }
396
398
 
397
-
398
-
399
399
  ```
400
400
 
401
401
  country class のpublic void tostring のvoidがエラーになっています。