Created
July 21, 2014 17:33
-
-
Save dekoza/67896e2e03a1b82bd80d to your computer and use it in GitHub Desktop.
zabawa z klasami na spotkaniu 6 kursu "Ukąś Pythona"
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
class Punkt: | |
def __init__(self, x, y): | |
self.x = x | |
self.y = y | |
def odl_od_punktu(self, other): | |
odl = ((self.x - other.x)**2 + (self.y - other.y)**2)**0.5 | |
return odl # float | |
def odl_od_centrum(self): | |
return self.odl_od_punktu(Punkt(0,0)) | |
class Kolo: | |
def __init__(self, centrum, r): | |
""" | |
Parametry: | |
centrum - obiekt klasy Punkt() | |
r - promień | |
""" | |
self.r = r | |
self.cntr = centrum # wer. a | |
def czy_wewnatrz(self, punkt): | |
return self.cntr.odl_od_punktu(punkt) <= self.r # wer. a | |
class Prostokat: | |
def __init__(self, wierzch1, wierzch2): | |
""" | |
wierzch1, wierzch2 - wierzchołki prostokąta, obiekty klasy Punkt | |
""" | |
def czy_wewnatrz(self, punkt): | |
return wynik # bool | |
def pole(self): | |
return wynik # float | |
class Odcinek: | |
def czy_przecina(self, odc): | |
return wynik # bool |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment