Don't like ads? PRO users don't see any ads ;-)
Guest

Race.groovy

By: a guest on Feb 10th, 2012  |  syntax: Groovy  |  size: 0.59 KB  |  hits: 111  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package racetrack
  2.  
  3. class Race {
  4.     String name
  5.     Date startDate
  6.     String city
  7.     String state
  8.     BigDecimal distance
  9.    
  10.     BigDecimal inMiles() {
  11.         return distance * 0.6214
  12.     }
  13.    
  14.     BigDecimal cost
  15.     Integer maxRunners = 100000
  16.        
  17.     static constraints = {
  18.         name(blank:false, maxSize:50)
  19.         startDate()
  20.         city()
  21.         state(inList:["GA", "NC", "SC", "VA"])
  22.         distance(min:0.0)
  23.         cost(min:0.0, max:100.0)
  24.         maxRunners(min:0, max:100000)
  25.        
  26.         startDate(validator: {return (it > new Date())})
  27.       }
  28. }