Permalink
Browse files

40:40 + p1 -> not over : green

  • Loading branch information...
ilkerde committed Feb 3, 2012
1 parent e140a62 commit a807ca1fc5485469847ae6f54da09b4d5971086f
Showing with 21 additions and 8 deletions.
  1. +21 −8 KataTennis.FSharp/src/Tennis.fs
@@ -15,17 +15,30 @@ type point =
let game = id
-let nextpoint p =
- match p with
- | Forty -> Win
- | _ -> p
-
let score player points =
let p1, p2 = points
- match player with
- | PlayerOne -> (nextpoint p1, p2)
- | PlayerTwo -> (p1, nextpoint p2)
+ let advance p =
+ match p with
+ | Forty -> Win
+ | _ -> p
+
+ let deuce =
+ match player with
+ | PlayerOne when p1 = Advantage -> (Win, Forty)
+ | PlayerTwo when p2 = Advantage -> (Forty, Win)
+ | _ -> (Forty, Forty)
+
+ let straight =
+ match player with
+ | PlayerOne -> (advance p1, p2)
+ | PlayerTwo -> (p1, advance p2)
+
+ match points with
+ | (Forty, Forty)
+ | (Advantage, _)
+ | (_, Advantage) -> deuce
+ | _ -> straight
let isover points =
match points with

0 comments on commit a807ca1

Please sign in to comment.