Created
December 3, 2008 10:21
-
-
Save zmalltalker/31492 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
| class Location: | |
| def __init__(self): | |
| pass | |
| def degreesPerHour(self): | |
| return self.degreesAtNoon / ((self.sunSetsAt - self.sunRisesAt) / 2) | |
| class Forecast: | |
| def __init__(self, startsAt): | |
| self.startsAt = startsAt | |
| pass | |
| def sunDegrees(self): | |
| if self.startsAt < self.location.sunRisesAt or self.startsAt > self.location.sunSetsAt: | |
| return 0 | |
| else: | |
| factor = self.location.degreesPerHour() | |
| numberOfHours = self.startsAt - self.location.sunRisesAt | |
| return factor * numberOfHours | |
| l = Location() | |
| l.sunRisesAt = 8 | |
| l.sunSetsAt = 16 | |
| l.degreesAtNoon = 90.0 | |
| f1 = Forecast(11) | |
| f2 = Forecast(8) | |
| f3 = Forecast(9) | |
| f4 = Forecast(12) | |
| f5 = Forecast(16) | |
| forecasts = [f1, f2, f3, f4, f5] | |
| for forecast in forecasts: | |
| forecast.location = l | |
| print forecast.startsAt | |
| print forecast.sunDegrees() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment