diff --git a/python-temel/staticmethod.2.py b/python-temel/staticmethod.2.py new file mode 100644 index 0000000..88440f7 --- /dev/null +++ b/python-temel/staticmethod.2.py @@ -0,0 +1,22 @@ +class Date: + def __init__(self, day, month, year): + self.day = day + self.month = month + self.year = year + + def disp(self): + print('{}/{}/{}'.format(self.day, self.month, self.year)) + + @staticmethod + def isLeapYear(year): + return year % 400 == 0 or year % 4 == 0 and year % 100 != 0 + +date = Date(10, 12, 2007) + +date.disp() # örnek metodun çağrılması için asıl biçim +Date.disp(date) # örnek metodun çağrılması için alternatif biçim +result = Date.isLeapYear(2000) # static metodun çağrılması için asıl biçim +print('Artık' if result else 'Artık değil') + +result = date.isLeapYear(2000) # static metodun çağrılması için alternatif biçim +print('Artık' if result else 'Artık değil') diff --git a/python-temel/staticmethod.2.py~ b/python-temel/staticmethod.2.py~ new file mode 100644 index 0000000..80ee7ba --- /dev/null +++ b/python-temel/staticmethod.2.py~ @@ -0,0 +1,22 @@ +class Date: + def __init__(self, day, month, year): + self.day = day + self.month = month + self.year = year + + def disp(self): + print('{}/{}/{}'.format(self.day, self.month, self.year)) + + @staticmethod + def isLeapYear(year): + return year % 400 == 0 or year % 4 == 0 and year % 100 != 0 + +date = Date(10, 12, 2007) + +date.disp() # örnek metodun çağrılması için asıl biçim +Date.disp(date) # örnek metodun çağrılması için alternatif biçim +result = Date.isLeapYear(2000) # static metodun çağrılması için asıl biçim +print('Artık' if result else 'Artık değil') + +result = date.isLeapYear(2000) # static metodun çağrılması için alternatif biçim +print('Artık' if result else 'Artık değil')