Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Tvar:
- def obsah():
- pass
- def obvod():
- pass
- class StranaAB:
- def __init__(self, strana_a, strana_b):
- self.strana_a = strana_a
- self.strana_b = strana_b
- def __str__(self):
- return "Strana a:" + str(self.strana_a) + " strana b " + str(self.strana_b)
- def spocitej_obvod(self):
- return 2*(self.strana_a + self.strana_b)
- def spocitej_obsah(self):
- return self.strana_a * self.strana_b
- class Kolecko(Tvar):
- def __init__(self, prumer):
- self.prumer = prumer
- def __str__(self):
- return "Kolecko ma prumer: " + str(self.prumer) + "Obvod:"+str(self.obvod)
- def obsah(self):
- return (self.prumer * self.prumer) * 3.14
- def obvod(self):
- return (2 * 3.14) * self.prumer
- class Ctyruhelnik(StranaAB):
- def __init__(self, strana_a, strana_b):
- StranaAB.__init__(self,strana_a, strana_b)
- def __str__(self):
- return "Ctyruheknik: " + StranaAB.__str__(self) + self.strana_c
- class Obdelnik(StranaAB):
- def __init__(self, strana_a, strana_b):
- StranaAB.__init__(self,strana_a, strana_b)
- def __str__(self):
- return "Obdelník: " + StranaAB.__str__(self)
- class Ctverec:
- def __init__(self, stranaA):
- self.stranaA = stranaA
- def obvod(self):
- return 4*(self.stranaA)
- def obsah(self):
- return self.stranaA * self.stranaA
- def __str__(self):
- return "Ctverec ma strany dlouhe: " + str(self.stranaA) + "cm" + "obvod:" +str(self.obvod)
- kolecko = Kolecko(25)
- ctyr = Ctyruhelnik(15, 10, 10)
- obdelnik = Obdelnik(10, 20)
- ctverec = Ctverec(12)
- print (kolecko)
- print (kolecko.obvod())
- print (kolecko.obsah())
- print (ctyr)
- print (ctyr.spocitej_obvod())
- print (ctyr.spocitej_obsah())
- print (obdelnik)
- print (obdelnik.spocitej_obvod())
- print (obdelnik.spocitej_obsah())
- print (ctverec)
- print (ctverec.obvod())
- print (ctverec.obsah())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement