File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 1
- case class Year ( year : Int ) {
2
- lazy val isLeap : Boolean = divisibleBy( 4 ) && (divisibleBy( 400 ) || ! divisibleBy( 100 ))
3
-
4
- private def divisibleBy (i : Int ) = year % i == 0
1
+ object Year {
2
+ def isLeap ( year : Int ) : Boolean = {
3
+ def divisibleBy ( i : Int ) = year % i == 0
4
+ divisibleBy(4 ) && (divisibleBy( 400 ) || ! divisibleBy( 100 ))}
5
5
}
Original file line number Diff line number Diff line change
1
+ object Year {
2
+ def isLeap (year : Int ): Boolean = ???
3
+ }
Original file line number Diff line number Diff line change @@ -2,31 +2,31 @@ import org.scalatest._
2
2
3
3
class LeapTest extends FunSuite {
4
4
test (" vanilla leap year" ) {
5
- assert(Year (1996 ).isLeap )
5
+ assert(Year .isLeap (1996 ))
6
6
}
7
7
8
8
test (" any old year" ) {
9
9
pending
10
- assert(! Year (1997 ).isLeap )
10
+ assert(! Year .isLeap (1997 ))
11
11
}
12
12
13
13
test(" an even year" ) {
14
14
pending
15
- assert(! Year (1986 ).isLeap )
15
+ assert(! Year .isLeap (1986 ))
16
16
}
17
17
18
18
test (" century" ) {
19
19
pending
20
- assert(! Year (1900 ).isLeap )
20
+ assert(! Year .isLeap (1900 ))
21
21
}
22
22
23
23
test (" exceptional century" ) {
24
24
pending
25
- assert(Year (2000 ).isLeap )
25
+ assert(Year .isLeap (2000 ))
26
26
}
27
27
28
28
test(" exceptional century that is no millenium" ) {
29
29
pending
30
- assert(Year (1600 ).isLeap )
30
+ assert(Year .isLeap (1600 ))
31
31
}
32
32
}
You can’t perform that action at this time.
0 commit comments