diff --git a/classes/classes.pdf b/classes/classes.pdf index 24030e1..7856e37 100644 Binary files a/classes/classes.pdf and b/classes/classes.pdf differ diff --git a/classes/classes.svg b/classes/classes.svg index 75544f6..5413523 100644 --- a/classes/classes.svg +++ b/classes/classes.svg @@ -150,57 +150,57 @@ id="text10059-0" y="1025.5997" x="988.58282" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:6.25px;line-height:0%;font-family:Oxygen;-inkscape-font-specification:Oxygen;text-align:end;letter-spacing:0px;word-spacing:0px;text-anchor:end;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:6.25px;line-height:0%;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans';text-align:end;letter-spacing:-0.28125px;word-spacing:0px;text-anchor:end;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;" xml:space="preserve"> + style="font-size:6.25px;line-height:1.25;-inkscape-font-specification:'Noto Sans';font-family:'Noto Sans';font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;letter-spacing:-0.35625px;" /> + style="font-size:6.25px;line-height:1.25;-inkscape-font-specification:'Noto Sans';font-family:'Noto Sans';font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;letter-spacing:-0.35625px;" /> © 2018 Miro Hrončok. Ke stažení na https://github.com/pyvec/cheatsheetsŠířeno pod licencí CC BY-SA: https://creativecommons.org/licenses/by-sa/4.0/Ukázky kódu šířeny pod licencí CC0: https://creativecommons.org/publicdomain/zero/1.0/Obrázek prasátka pod licencí CC0 z https://opengameart.org/content/animal-pack-redux @@ -457,7 +457,7 @@ style="font-size:25.00000191px;line-height:1.25;stroke-width:1px">Třídy a objekty mikes = Kotatko('Mikeš') + style="font-size:11.25px;line-height:1.25999999;letter-spacing:-0.328125px;">mikes = Kotatko('Mikeš') Vlastní třída, neboli typVlastní třída, neboli typInicializace objektu, může přebírat argumentyInicializace objektu, může přebírat argumentyNastavení atributu objektu + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11.25px;line-height:1.25999999;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans';letter-spacing:-0.328125px;">Nastavení atributu objektu class Zviratko:class Zviratko: def __init__(self, jmeno): def __init__(self, jmeno): self.jmeno = jmeno + style="font-size:11.25px;line-height:1.25999999;letter-spacing:-0.328125px;"> self.jmeno = jmeno def snez(self, jidlo): print(self.jmeno, 'jí', jidlo) Metoda – první argument je selfselfclass Kotatko(Zviratko): def zamnoukej(self):Dědičnost (koťátko je druh zvířátka)Dědičnost (koťátko je druh zvířátka)Metoda specifická pro koťátka + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11.25px;line-height:1.25999999;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans';letter-spacing:-0.328125px;">Metoda specifická pro koťátka @@ -606,35 +606,35 @@ id="text3191" y="570.86072" x="20.767212" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Oxygen Mono';-inkscape-font-specification:'Oxygen Mono';text-align:start;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Droid Sans Mono';-inkscape-font-specification:'Droid Sans Mono';text-align:start;letter-spacing:-0.328125px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;" xml:space="preserve">class Prasatko(Zviratko): def zakvic(self): print(self.jmeno, 'kví!') Dědičnost (prasátko je druh zvířátka) def snez(self, jidlo): self.zakvic() super().snez(jidlo) print(self.jmeno, 'se po jídle válí v bahně!') @@ -677,23 +677,23 @@ id="text4643" y="627.15796" x="285.50717" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Oxygen Mono';-inkscape-font-specification:'Oxygen Mono';text-align:start;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Droid Sans Mono';-inkscape-font-specification:'Droid Sans Mono';text-align:start;letter-spacing:-0.328125px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;" xml:space="preserve">Přepisování metody předkaPřepisování metody předkaVolání vlastní metodyVolání vlastní metodyVolání metody jako na předkovi + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11.25px;line-height:1.25999999;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans';letter-spacing:-0.328125px;">Volání metody jako na předkovi + style="opacity:1;fill:#ee9fee;fill-opacity:0.80056978;stroke:none;stroke-width:3.85450816;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> prasatko = Prasatko('Ťulda') Volání metody + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:11.25px;line-height:1.25999999;font-family:'Noto Sans';-inkscape-font-specification:'Noto Sans';letter-spacing:-0.328125px;">Volání metody @@ -763,41 +763,41 @@ id="text4323" y="783.70648" x="20.767212" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Oxygen Mono';-inkscape-font-specification:'Oxygen Mono';text-align:start;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Droid Sans Mono';-inkscape-font-specification:'Droid Sans Mono';text-align:start;letter-spacing:-0.328125px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;" xml:space="preserve">karlicka = Prasatko('Karlička')print(karlicka.jmeno)karlicka.jmeno = 'Karla' Objektů jedné třídy může být vícMůžeme se dívat na jejich atributyA taky je měnit @@ -838,31 +838,31 @@ id="text4463" y="882.53223" x="20.767212" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Oxygen Mono';-inkscape-font-specification:'Oxygen Mono';text-align:start;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Droid Sans Mono';-inkscape-font-specification:'Droid Sans Mono';text-align:start;letter-spacing:-0.328125px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;" xml:space="preserve">for zviratko in [prasatko, karlicka, mikes, Kotatko('Mourek')]: zviratko.snez('papání') Nevíme jestli to je prasátko nebo koťátko, ale to nevadí, tohle funguje @@ -906,40 +906,40 @@ id="text1271" y="938.70178" x="20.767212" - style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Oxygen Mono';-inkscape-font-specification:'Oxygen Mono';text-align:start;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Droid Sans Mono';-inkscape-font-specification:'Droid Sans Mono';text-align:start;letter-spacing:-0.328125px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;" xml:space="preserve"> isinstance(zviratko, Zviratko) type(zviratko) == Zviratko Je instancí zvířátka? AnoJe třídou objektu Zviratko? Ne