Created
March 10, 2010 17:27
-
-
Save saimonmoore/328110 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| waxClass{"PolygonShape", NSObject} | |
| function initWithNumberOfSides_minimumNumberOfSides_maximumNumberOfSides(self, sides, min, max) | |
| self.super:init() | |
| self._minimumNumberOfSides = min | |
| self._maximumNumberOfSides = max | |
| self._numberOfSides = sides | |
| return self | |
| end | |
| function init(self) | |
| return self:initWithNumberOfSides_minimumNumberOfSides_maximumNumberOfSides(6,3,12) | |
| end | |
| --Setters/Getters | |
| function numberOfSides(self, sides) | |
| if sides then | |
| if sides < 3 then error('Minimum 3 sides for a polyogn') end | |
| if sides < self._minimumNumberOfSides then error("Value can't be less than minimumNumberOfSides") end | |
| if sides > self._maximumNumberOfSides then error("Value can't be less than maximumNumberOfSides") end | |
| self._numberOfSides = sides | |
| else | |
| return self._numberOfSides | |
| end | |
| end | |
| function minimumNumberOfSides(self, minSides) | |
| if minSides then | |
| if minSides < 3 then error('Minimum 3 sides for a polyogn') end | |
| if minSides >= self._maximumNumberOfSides then error("Value can't be greater than or equal to maximumNumberOfSides") end | |
| self._minimumNumberOfSides = minSides | |
| else | |
| return self._minimumNumberOfSides | |
| end | |
| end | |
| function maximumNumberOfSides(self, maxSides) | |
| if maxSides then | |
| if maxSides > 12 then error('Maximum 12 sides for a polyogn') end | |
| if maxSides <= self._minimumNumberOfSides then error("Value can't be less than or equal to minimumNumberOfSides") end | |
| self._maximumNumberOfSides = maxSides | |
| else | |
| return self._maximumNumberOfSides | |
| end | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment