@@ -9,21 +9,16 @@ object Objects extends FlatSpec with Matchers with org.scalaexercises.definition
9
9
10
10
/** An object is a singleton. One object, that's it. This object is a replacement of static in Java, and is called upon much in the same way:
11
11
*/
12
- def singletonObjects (res0 : String , res1 : String , res2 : String , res3 : String ) {
12
+ def singletonObjects (res0 : String , res1 : String ) {
13
13
object Greeting {
14
14
def english = " Hi"
15
15
16
16
def espanol = " Hola"
17
17
18
- def deutsch = " Hallo"
19
-
20
- def magyar = " Szia"
21
18
}
22
19
23
20
Greeting .english should be(res0)
24
21
Greeting .espanol should be(res1)
25
- Greeting .deutsch should be(res2)
26
- Greeting .magyar should be(res3)
27
22
}
28
23
29
24
/** Here is a proof that an object is a singleton, and not a static method in a class:
@@ -33,10 +28,6 @@ object Objects extends FlatSpec with Matchers with org.scalaexercises.definition
33
28
def english = " Hi"
34
29
35
30
def espanol = " Hola"
36
-
37
- def deutsch = " Hallo"
38
-
39
- def magyar = " Szia"
40
31
}
41
32
42
33
val x = Greeting
@@ -71,7 +62,7 @@ object Objects extends FlatSpec with Matchers with org.scalaexercises.definition
71
62
72
63
/** A companion object can also see private values and variables of the corresponding classes' instantiated objects:
73
64
*/
74
- def privateValuesObjects (res0 : String , res1 : String , res2 : String , res3 : String ) {
65
+ def privateValuesObjects (res0 : String , res1 : String ) {
75
66
class Person (val name : String , private val superheroName : String ) // The superhero name is private!
76
67
77
68
object Person {
@@ -80,13 +71,9 @@ object Objects extends FlatSpec with Matchers with org.scalaexercises.definition
80
71
81
72
val clark = new Person (" Clark Kent" , " Superman" )
82
73
val peter = new Person (" Peter Parker" , " Spiderman" )
83
- val bruce = new Person (" Bruce Wayne" , " Batman" )
84
- val diana = new Person (" Diana Prince" , " Wonder Woman" )
85
74
86
75
Person .showMeInnerSecret(clark) should be(res0)
87
76
Person .showMeInnerSecret(peter) should be(res1)
88
- Person .showMeInnerSecret(bruce) should be(res2)
89
- Person .showMeInnerSecret(diana) should be(res3)
90
77
}
91
78
92
79
}
0 commit comments