Created
February 1, 2011 14:09
-
-
Save monstermunchkin/805902 to your computer and use it in GitHub Desktop.
WS08/09 Aufgabe 3
This file contains 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
#!/usr/bin/python2 | |
class Datum09(object): | |
def __init__(self, Tag=4, Monat=2): | |
self.__hv = (31, 28, 30, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) | |
self.__wt = ('Donnerstag', 'Freitag', 'Samstag', 'Sonntag', | |
'Montag', 'Dienstag', 'Mittwoch') | |
if Monat not in range(1,13) or Tag not in range(1,self.__hv[Monat-1]+1): | |
print 'Fehlerhafte Eingabe. Werte werden auf 4 und 2 gesetzt' | |
self.__tag = 4 | |
self.__monat = 2 | |
else: | |
self.__tag = Tag | |
self.__monat = Monat | |
def wochenTag(self): | |
tage = sum(self.__hv[:self.__monat-1]) + self.__tag-1 | |
return self.__wt[tage % 7] | |
def ausgabe(self): | |
print '{0}, {1}.{2}.2009'.format(self.wochenTag(), self.__tag, | |
self.__monat) | |
def addiereTage(self, Tage): | |
tage = sum(self.__hv[:self.__monat-1]) + self.__tag | |
tage = tage + Tage | |
monat = 1 | |
for i in self.__hv: | |
if tage - i > 0: | |
monat = monat + 1 | |
tage = tage - i | |
else: | |
break | |
self.__tag = tage | |
self.__monat = monat | |
if __name__ == '__main__': | |
meinDatum = Datum09() | |
meinDatum.addiereTage(30) | |
meinDatum.ausgabe() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment