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 ))}
55}
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._
22
33class LeapTest extends FunSuite {
44 test (" vanilla leap year" ) {
5- assert(Year (1996 ).isLeap )
5+ assert(Year .isLeap (1996 ))
66 }
77
88 test (" any old year" ) {
99 pending
10- assert(! Year (1997 ).isLeap )
10+ assert(! Year .isLeap (1997 ))
1111 }
1212
1313 test(" an even year" ) {
1414 pending
15- assert(! Year (1986 ).isLeap )
15+ assert(! Year .isLeap (1986 ))
1616 }
1717
1818 test (" century" ) {
1919 pending
20- assert(! Year (1900 ).isLeap )
20+ assert(! Year .isLeap (1900 ))
2121 }
2222
2323 test (" exceptional century" ) {
2424 pending
25- assert(Year (2000 ).isLeap )
25+ assert(Year .isLeap (2000 ))
2626 }
2727
2828 test(" exceptional century that is no millenium" ) {
2929 pending
30- assert(Year (1600 ).isLeap )
30+ assert(Year .isLeap (1600 ))
3131 }
3232}
You can’t perform that action at this time.
0 commit comments