Skip to content

Instantly share code, notes, and snippets.

@barron9
Created June 27, 2021 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barron9/cc1327e55a709432af3c2f0b515d2dd5 to your computer and use it in GitHub Desktop.
Save barron9/cc1327e55a709432af3c2f0b515d2dd5 to your computer and use it in GitHub Desktop.
class test{
//takes package parent class
init(package: Package,price :Int64) {
do{
try 8 * 100/package.setPrice(price:price)
print("done")
}catch {
print("price value must be greater than 0 _ \(price) ")
}
}
}
test(package: Package(),price: 10) //no issues
test(package: Pro(),price: 999) //error //strentened pre conds
test(package: Basic(),price: 999) //error //strentened pre conds
test(package: Basic(),price: 999) //error //weakened post condition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment