Skip to content

Instantly share code, notes, and snippets.

@mrerrormessage
Forked from TheBizzle/WidgetJunk.scala
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mrerrormessage/ebf66e04cea2533648ed to your computer and use it in GitHub Desktop.
Save mrerrormessage/ebf66e04cea2533648ed to your computer and use it in GitHub Desktop.
abstract class InputBoxType[T](val name:String)
case object Num extends InputBoxType[Double]("Number")
case object Str extends InputBoxType[String]("String")
case object StrReporter extends InputBoxType[String]("String (reporter)")
case object StrCommand extends InputBoxType[String]("String (commands)")
case object Col extends InputBoxType[Int]("Color")
case class InputBox[T](left: Int = 0, top: Int = 0, right: Int = 0, bottom: Int = 0, varName: String, value: T, multiline: Boolean = false, boxtype: InputBoxType[T]){
def say: String = boxtype match {
case c: Col.type => "hello"
case _ => "goodbye"
}
}
val ib = InputBox(0, 0, 0, 0, "apples", 9001, false, Col)
val ib2 = InputBox(0, 0, 0, 0, "apples", 9001.0, false, Num)
abstract class InputBoxType[T](val name:String)
case object Num extends InputBoxType[Double]("Number")
case object Str extends InputBoxType[String]("String")
case object StrReporter extends InputBoxType[String]("String (reporter)")
case object StrCommand extends InputBoxType[String]("String (commands)")
case object Col extends InputBoxType[Int]("Color")
case class InputBox[T](left: Int = 0, top: Int = 0, right: Int = 0, bottom: Int = 0, varName: String, value: T, multiline: Boolean = false, boxtype: InputBoxType[T]){
def say: String = boxtype match {
case Col => "hello"
case _ => "goodbye"
}
}
val ib = InputBox(0, 0, 0, 0, "apples", 9001, false, Col)
val ib2 = InputBox(0, 0, 0, 0, "apples", 9001.0, false, Num)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment