Skip to content

Commit a6794c3

Browse files
Fix formatting
1 parent eb8d6f7 commit a6794c3

File tree

8 files changed

+110
-110
lines changed

8 files changed

+110
-110
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.baeldung.scala.traits
22

33
trait Composition extends Orchestration with Mixing {
4-
var composer: String
4+
var composer: String
55

6-
def compose(): String
6+
def compose(): String
77

8-
var studio: String
8+
var studio: String
99

10-
def getStudio(): String = s"Composed at studio $studio"
10+
def getStudio(): String = s"Composed at studio $studio"
1111
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.baeldung.scala.traits
22

33
trait Mixing {
4-
var mixer: String
5-
val qualityRatio: Double = 3.14
4+
var mixer: String
5+
val qualityRatio: Double = 3.14
66

7-
def algorithm: MixingAlgorithm = HighInstrumentalQuality
7+
def algorithm: MixingAlgorithm = HighInstrumentalQuality
88
}

core-scala/src/main/scala/com/baeldung/scala/traits/MixingAlgorithm.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package com.baeldung.scala.traits
33
sealed trait MixingAlgorithm
44

55
case object LowInstrumentalQuality extends MixingAlgorithm {
6-
override def toString(): String = "Low instrumental quality"
6+
override def toString(): String = "Low instrumental quality"
77
}
88

99
case object HighInstrumentalQuality extends MixingAlgorithm {
10-
override def toString(): String = "High instrumental quality"
10+
override def toString(): String = "High instrumental quality"
1111
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.baeldung.scala.traits
22

33
trait Orchestration {
4-
var orchestra: String
4+
var orchestra: String
55
}

core-scala/src/main/scala/com/baeldung/scala/traits/Score.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ class Score(var composer: String,
88
var studio: String)
99
extends RecordLabel with Composition with SoundProduction {
1010

11-
override def compose(): String =
12-
s"""The score is composed by $composer,
13-
|Orchestration by $orchestra,
14-
|Mixed by $mixer""".stripMargin
11+
override def compose(): String =
12+
s"""The score is composed by $composer,
13+
|Orchestration by $orchestra,
14+
|Mixed by $mixer""".stripMargin
1515

16-
override def produce(): String = s"The score is produced by $engineer"
16+
override def produce(): String = s"The score is produced by $engineer"
1717

18-
override def algorithm(): MixingAlgorithm = {
19-
if (qualityRatio < 3) LowInstrumentalQuality
20-
else super.algorithm
21-
}
18+
override def algorithm(): MixingAlgorithm = {
19+
if (qualityRatio < 3) LowInstrumentalQuality
20+
else super.algorithm
21+
}
2222

23-
override def getStudio(): String =
24-
super[Composition].getStudio() + ", " + super[SoundProduction].getStudio()
23+
override def getStudio(): String =
24+
super[Composition].getStudio() + ", " + super[SoundProduction].getStudio()
2525
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.baeldung.scala.traits
22

33
trait SoundProduction {
4-
this: RecordLabel =>
5-
var engineer: String
4+
this: RecordLabel =>
5+
var engineer: String
66

7-
def produce(): String
7+
def produce(): String
88

9-
var studio: String
9+
var studio: String
1010

11-
def getStudio(): String = s"Produced at studio $studio"
11+
def getStudio(): String = s"Produced at studio $studio"
1212
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.baeldung.scala.traits
22

33
trait Vocals {
4-
val sing: String = "Vocals mixin"
4+
val sing: String = "Vocals mixin"
55
}

core-scala/src/test/scala/com/baeldung/scala/traits/ScoreUnitTest.scala

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -5,87 +5,87 @@ import org.junit.Test
55

66
class ScoreUnitTest {
77

8-
@Test
9-
def givenScore_whenComposeCalled_thenCompositionIsReturned() = {
10-
11-
val composer = "Hans Zimmer"
12-
val engineer = "Matt Dunkley"
13-
val orchestra = "Berlin Philharmonic"
14-
val mixer = "Dave Stewart"
15-
val studio = "Abbey Studios"
16-
val score = new Score(composer, engineer, orchestra, mixer, 10, studio)
17-
18-
assertEquals(score.compose(),
19-
s"""The score is composed by $composer,
20-
|Orchestration by $orchestra,
21-
|Mixed by $mixer""".stripMargin)
22-
}
23-
24-
@Test
25-
def givenScore_whenProduceCalled_thenSoundProductionIsReturned() = {
26-
27-
val composer = "Hans Zimmer"
28-
val engineer = "Matt Dunkley"
29-
val orchestra = "Berlin Philharmonic"
30-
val mixer = "Dave Stewart"
31-
val studio = "Abbey Studios"
32-
val score = new Score(composer, engineer, orchestra, mixer, 3, studio)
33-
34-
assertEquals(score.produce(), s"The score is produced by $engineer")
35-
}
36-
37-
@Test
38-
def givenScore_whenLowQualityRatioSet_thenCorrectAlgorithmIsReturned() = {
39-
40-
val composer = "Hans Zimmer"
41-
val engineer = "Matt Dunkley"
42-
val orchestra = "Berlin Philharmonic"
43-
val mixer = "Dave Stewart"
44-
val studio = "Abbey Studios"
45-
val score = new Score(composer, engineer, orchestra, mixer, 1, studio)
46-
47-
assertEquals(score.algorithm().toString, "Low instrumental quality")
48-
}
49-
50-
@Test
51-
def givenScore_whenHighQualityRatioSet_thenCorrectAlgorithmIsReturned() = {
52-
53-
val composer = "Hans Zimmer"
54-
val engineer = "Matt Dunkley"
55-
val orchestra = "Berlin Philharmonic"
56-
val mixer = "Dave Stewart"
57-
val studio = "Abbey Studios"
58-
val score = new Score(composer, engineer, orchestra, mixer, 10, studio)
59-
60-
assertEquals(score.algorithm().toString, "High instrumental quality")
61-
}
62-
63-
@Test
64-
def givenScore_whenVocalsMixinAttached_thenSingCanBeCalled() = {
65-
66-
val composer = "Hans Zimmer"
67-
val engineer = "Matt Dunkley"
68-
val orchestra = "Berlin Philharmonic"
69-
val mixer = "Dave Stewart"
70-
val studio = "Abbey Studios"
71-
val score = new Score(composer, engineer, orchestra, mixer, 10, studio) with Vocals
72-
73-
assertEquals(score.sing, "Vocals mixin")
74-
}
75-
76-
@Test
77-
def givenScore_whenGetStudioCalled_thenStudiosAreReturned() = {
78-
79-
val composer = "Hans Zimmer"
80-
val engineer = "Matt Dunkley"
81-
val orchestra = "Berlin Philharmonic"
82-
val mixer = "Dave Stewart"
83-
val studio = "Abbey Studios"
84-
val score = new Score(composer, engineer, orchestra, mixer, 10, studio)
85-
86-
assertEquals(
87-
score.getStudio(),
88-
s"Composed at studio $studio, Produced at studio $studio"
89-
)
90-
}
8+
@Test
9+
def givenScore_whenComposeCalled_thenCompositionIsReturned() = {
10+
11+
val composer = "Hans Zimmer"
12+
val engineer = "Matt Dunkley"
13+
val orchestra = "Berlin Philharmonic"
14+
val mixer = "Dave Stewart"
15+
val studio = "Abbey Studios"
16+
val score = new Score(composer, engineer, orchestra, mixer, 10, studio)
17+
18+
assertEquals(score.compose(),
19+
s"""The score is composed by $composer,
20+
|Orchestration by $orchestra,
21+
|Mixed by $mixer""".stripMargin)
22+
}
23+
24+
@Test
25+
def givenScore_whenProduceCalled_thenSoundProductionIsReturned() = {
26+
27+
val composer = "Hans Zimmer"
28+
val engineer = "Matt Dunkley"
29+
val orchestra = "Berlin Philharmonic"
30+
val mixer = "Dave Stewart"
31+
val studio = "Abbey Studios"
32+
val score = new Score(composer, engineer, orchestra, mixer, 3, studio)
33+
34+
assertEquals(score.produce(), s"The score is produced by $engineer")
35+
}
36+
37+
@Test
38+
def givenScore_whenLowQualityRatioSet_thenCorrectAlgorithmIsReturned() = {
39+
40+
val composer = "Hans Zimmer"
41+
val engineer = "Matt Dunkley"
42+
val orchestra = "Berlin Philharmonic"
43+
val mixer = "Dave Stewart"
44+
val studio = "Abbey Studios"
45+
val score = new Score(composer, engineer, orchestra, mixer, 1, studio)
46+
47+
assertEquals(score.algorithm().toString, "Low instrumental quality")
48+
}
49+
50+
@Test
51+
def givenScore_whenHighQualityRatioSet_thenCorrectAlgorithmIsReturned() = {
52+
53+
val composer = "Hans Zimmer"
54+
val engineer = "Matt Dunkley"
55+
val orchestra = "Berlin Philharmonic"
56+
val mixer = "Dave Stewart"
57+
val studio = "Abbey Studios"
58+
val score = new Score(composer, engineer, orchestra, mixer, 10, studio)
59+
60+
assertEquals(score.algorithm().toString, "High instrumental quality")
61+
}
62+
63+
@Test
64+
def givenScore_whenVocalsMixinAttached_thenSingCanBeCalled() = {
65+
66+
val composer = "Hans Zimmer"
67+
val engineer = "Matt Dunkley"
68+
val orchestra = "Berlin Philharmonic"
69+
val mixer = "Dave Stewart"
70+
val studio = "Abbey Studios"
71+
val score = new Score(composer, engineer, orchestra, mixer, 10, studio) with Vocals
72+
73+
assertEquals(score.sing, "Vocals mixin")
74+
}
75+
76+
@Test
77+
def givenScore_whenGetStudioCalled_thenStudiosAreReturned() = {
78+
79+
val composer = "Hans Zimmer"
80+
val engineer = "Matt Dunkley"
81+
val orchestra = "Berlin Philharmonic"
82+
val mixer = "Dave Stewart"
83+
val studio = "Abbey Studios"
84+
val score = new Score(composer, engineer, orchestra, mixer, 10, studio)
85+
86+
assertEquals(
87+
score.getStudio(),
88+
s"Composed at studio $studio, Produced at studio $studio"
89+
)
90+
}
9191
}

0 commit comments

Comments
 (0)