Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. class Tvar:
  2. def obsah():
  3. pass
  4.  
  5. def obvod():
  6. pass
  7.  
  8. class StranaAB:
  9. def __init__(self, strana_a, strana_b):
  10. self.strana_a = strana_a
  11. self.strana_b = strana_b
  12.  
  13. def __str__(self):
  14. return "Strana a:" + str(self.strana_a) + " strana b " + str(self.strana_b)
  15.  
  16. def spocitej_obvod(self):
  17. return 2*(self.strana_a + self.strana_b)
  18.  
  19. def spocitej_obsah(self):
  20. return self.strana_a * self.strana_b
  21.  
  22. class Kolecko(Tvar):
  23. def __init__(self, prumer):
  24. self.prumer = prumer
  25.  
  26. def __str__(self):
  27. return "Kolecko ma prumer: " + str(self.prumer) + "Obvod:"+str(self.obvod)
  28.  
  29. def obsah(self):
  30. return (self.prumer * self.prumer) * 3.14
  31.  
  32. def obvod(self):
  33. return (2 * 3.14) * self.prumer
  34. class Ctyruhelnik(StranaAB):
  35. def __init__(self, strana_a, strana_b):
  36. StranaAB.__init__(self,strana_a, strana_b)
  37. def __str__(self):
  38. return "Ctyruheknik: " + StranaAB.__str__(self) + self.strana_c
  39.  
  40. class Obdelnik(StranaAB):
  41. def __init__(self, strana_a, strana_b):
  42. StranaAB.__init__(self,strana_a, strana_b)
  43.  
  44. def __str__(self):
  45. return "Obdelník: " + StranaAB.__str__(self)
  46.  
  47. class Ctverec:
  48. def __init__(self, stranaA):
  49. self.stranaA = stranaA
  50. def obvod(self):
  51. return 4*(self.stranaA)
  52.  
  53. def obsah(self):
  54. return self.stranaA * self.stranaA
  55.  
  56. def __str__(self):
  57. return "Ctverec ma strany dlouhe: " + str(self.stranaA) + "cm" + "obvod:" +str(self.obvod)
  58.  
  59. kolecko = Kolecko(25)
  60. ctyr = Ctyruhelnik(15, 10, 10)
  61. obdelnik = Obdelnik(10, 20)
  62. ctverec = Ctverec(12)
  63.  
  64. print (kolecko)
  65. print (kolecko.obvod())
  66. print (kolecko.obsah())
  67.  
  68. print (ctyr)
  69. print (ctyr.spocitej_obvod())
  70. print (ctyr.spocitej_obsah())
  71.  
  72. print (obdelnik)
  73. print (obdelnik.spocitej_obvod())
  74. print (obdelnik.spocitej_obsah())
  75.  
  76. print (ctverec)
  77. print (ctverec.obvod())
  78. print (ctverec.obsah())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement