Reputation: 965
i have a trait named UserT and a class DirectUserT extending the trait i want to add enum in the trait so that child classes can use it i have made a scala Object UserStatus which extends Enumeration now i want to have this enum in my trait so that child classes can use it but i dont know how should i do is ?
my enum object
package testlogic
object UserStatus extends Enumeration{
type UserStatus = Value
val ACTIVE , INACTIVE , BLOCKED , DELETED = Value
}
here is my code for UserT
package testlogic
import testlogic.UserStatus._
trait UserT {
var name : String = ""
def setName( aName: String)= {
name = aName
}
def getName : String = {
name
}
}
DirectUserT.scala
package testlogic
class DirectuserT extends UserT {
var currentStatus =BLOCKED
//println(currentStatus)
}
eclipse shows error on BLOCKED
Please help
Upvotes: 0
Views: 546
Reputation: 1815
You need to add
import testlogic.UserStatus._
to you class DirectUserT.scala
Or add it within your trait:
trait UserT {
import testlogic.UserStatus._
}
Upvotes: 2