TI/Skrypty z zajęć/k6a
Z Brain-wiki
# -*- coding: utf-8 -*-
"""
Created on Wed May 27 11:50:27 2020
@author: Tomek
"""
class rownoleglobok():
def __init__(self, a, b):
print('wywolanie init z klasy rownoleglobok')
self.__a = a
self.__b = b
@property
def a(self):
return self.__a
@property
def b(self):
return self.__b
def __str__(self):
return 'Rownoleglobok o bokach ' + str(self.__a) + ', ' + str(self.__b)
def __repr__(self):
return str(self)
@property
def obwod(self):
return 2* (self.__a + self.__b)
class prostokat(rownoleglobok):
# def __init__(self, a, b):
# print('wywolanie init z klasy prostokat')
# super().__init__(a, b)
@property
def pole(self):
return self.a*self.b
# def __str__(self):
# return 'Jakis prostokat'
class kwadrat(prostokat):
def __init__(self, a):
print('wywolanie init z klasy kwadrat')
super().__init__(a, a)
def __str__(self):
return super().__str__() + ' ale bedacy kwadratem'
k = kwadrat(5)
print(k)