Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //9.1
- //a)
- class Time(private[this] var h:Int){
- if(h<0) h=0
- def hour: Int = h //getter
- def hour_=(x: Int) { //setter
- if(x>0) h=x
- else h=0
- }
- object Time{
- def apply(h:Int) = new Time(h)
- }
- }
- // i teraz wywoluje:
- // val g=Time(-3)
- // i czy nie powinno wyrzucic g:Time=0?
- // wychodzi mi g:Time=-3, dlaczego
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement