Advertisement
Guest User

Untitled

a guest
Dec 15th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.30 KB | None | 0 0
  1. class Time1ab(private[this] var z:Int){
  2. if(z<0) z=0
  3. def hour: Int=z
  4. def hour_=(x:Int){
  5.   if(x>0){
  6.       z=x
  7.     }
  8.     else{z=0}
  9. }
  10. }
  11. object Time1ab{
  12. def apply(h:Int)=new Time1ab(h)
  13. }
  14.  
  15.  
  16. //main
  17. object app {
  18.   def main(Args:Array[String]) {
  19.     val g = Time1ab(-3)
  20.     g.hour
  21.     println(g.hour)
  22.   }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement