Skip to content

Instantly share code, notes, and snippets.

@mabster
Created July 30, 2012 01:03
Show Gist options
  • Save mabster/3203077 to your computer and use it in GitHub Desktop.
Save mabster/3203077 to your computer and use it in GitHub Desktop.
Pig Gives Birth
// the business logic for the creation of a new litter
Find the pig with the given id to make sure it's on the user's farm, female and pregnant. If not, return error.
Find the pig's most recent mating, which should be in a gestating state. If not, return error.
If it's been less than 100 days or more than 130 days since the mating, return error.
Update the mating to a successful state.
Update the pig to a lactating state.
Create a new birth event.
Create a new litter with the given number of piglets and the pig as the mother.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment