We have a public trait Phone and two implementations. We don't want to disclose the implementations of these models, so we made them private. But we need two methods in order to get a stable model and an experimental one. Implement these methods without revealing hidden data.
Companion objects
Multiply apply
Report a typo
Sample Input 1:
Sample Output 1:
X100P20
Y100P42Write a program in Scala 3
trait Phone:
def serialNumber: String
object Phone:
// Stable
private class PhoneX extends Phone:
val serialNumber: String = "X100P20"
// Experimental
private class PhoneY extends Phone:
val serialNumber: String = "Y100P42"
def getStableModel: Phone = ???
def getExperimentalModel: Phone = ???
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.