【发布时间】:2015-06-08 06:19:12
【问题描述】:
我有一个名为 UserT 的特征和一个扩展该特征的类 DirectUserT 我想在特征中添加枚举,以便子类可以使用它 我制作了一个扩展枚举的 scala 对象 UserStatus 现在我想在我的 trait 中加入这个枚举,以便子类可以使用它,但我不知道该怎么做?
我的枚举对象
package testlogic
object UserStatus extends Enumeration{
type UserStatus = Value
val ACTIVE , INACTIVE , BLOCKED , DELETED = Value
}
这是我的 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 在 BLOCKED 上显示错误
请帮忙
【问题讨论】: