Vererbung_Aufgabe_1
Mesic_Klassen_1.cpp@5:0c5eeee1465b, 2020-04-28 (annotated)
- Committer:
- mirzamesic
- Date:
- Tue Apr 28 14:46:56 2020 +0000
- Revision:
- 5:0c5eeee1465b
- Parent:
- 1:8e854723c742
Ver2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mirzamesic | 1:8e854723c742 | 1 | |
mirzamesic | 1:8e854723c742 | 2 | #include <stdio.h> |
mirzamesic | 1:8e854723c742 | 3 | #include <iostream> |
mirzamesic | 1:8e854723c742 | 4 | using namespace std; |
mirzamesic | 1:8e854723c742 | 5 | |
mirzamesic | 1:8e854723c742 | 6 | enum eckig { ja, nein}; |
mirzamesic | 1:8e854723c742 | 7 | |
mirzamesic | 1:8e854723c742 | 8 | namespace Mesic |
mirzamesic | 1:8e854723c742 | 9 | { |
mirzamesic | 1:8e854723c742 | 10 | class Kreis |
mirzamesic | 1:8e854723c742 | 11 | { |
mirzamesic | 1:8e854723c742 | 12 | private: |
mirzamesic | 1:8e854723c742 | 13 | float m_radius; |
mirzamesic | 1:8e854723c742 | 14 | eckig m_hat_ecken; |
mirzamesic | 1:8e854723c742 | 15 | |
mirzamesic | 1:8e854723c742 | 16 | public: |
mirzamesic | 1:8e854723c742 | 17 | float berechneUmfang(); |
mirzamesic | 1:8e854723c742 | 18 | float berechneFlaeche(); |
mirzamesic | 1:8e854723c742 | 19 | eckig eckingauslesen(); |
mirzamesic | 1:8e854723c742 | 20 | |
mirzamesic | 1:8e854723c742 | 21 | Kreis(float radius); |
mirzamesic | 1:8e854723c742 | 22 | Kreis(float radius, eckig hat_ecken); |
mirzamesic | 1:8e854723c742 | 23 | |
mirzamesic | 1:8e854723c742 | 24 | Kreis(); |
mirzamesic | 1:8e854723c742 | 25 | }; |
mirzamesic | 1:8e854723c742 | 26 | |
mirzamesic | 1:8e854723c742 | 27 | } |
mirzamesic | 1:8e854723c742 | 28 | |
mirzamesic | 1:8e854723c742 | 29 | using namespace Mesic; |
mirzamesic | 1:8e854723c742 | 30 | Kreis::Kreis(float radius) |
mirzamesic | 1:8e854723c742 | 31 | { |
mirzamesic | 1:8e854723c742 | 32 | m_radius = radius; |
mirzamesic | 1:8e854723c742 | 33 | m_hat_ecken = nein; |
mirzamesic | 1:8e854723c742 | 34 | } |
mirzamesic | 1:8e854723c742 | 35 | |
mirzamesic | 1:8e854723c742 | 36 | Kreis::Kreis(float radius,eckig hat_ecken) |
mirzamesic | 1:8e854723c742 | 37 | { |
mirzamesic | 1:8e854723c742 | 38 | m_radius = radius; |
mirzamesic | 1:8e854723c742 | 39 | m_hat_ecken = nein; |
mirzamesic | 1:8e854723c742 | 40 | } |
mirzamesic | 1:8e854723c742 | 41 | |
mirzamesic | 1:8e854723c742 | 42 | Kreis::Kreis() |
mirzamesic | 1:8e854723c742 | 43 | { |
mirzamesic | 1:8e854723c742 | 44 | m_radius = 0; |
mirzamesic | 1:8e854723c742 | 45 | m_hat_ecken = nein; |
mirzamesic | 1:8e854723c742 | 46 | } |
mirzamesic | 1:8e854723c742 | 47 | |
mirzamesic | 1:8e854723c742 | 48 | float Kreis::berechneUmfang() |
mirzamesic | 1:8e854723c742 | 49 | { |
mirzamesic | 1:8e854723c742 | 50 | return (m_radius * m_radius * 3.1415); |
mirzamesic | 1:8e854723c742 | 51 | } |
mirzamesic | 1:8e854723c742 | 52 | |
mirzamesic | 1:8e854723c742 | 53 | eckig Kreis::eckingauslesen() |
mirzamesic | 1:8e854723c742 | 54 | { |
mirzamesic | 1:8e854723c742 | 55 | return(m_hat_ecken); |
mirzamesic | 1:8e854723c742 | 56 | } |
mirzamesic | 1:8e854723c742 | 57 | |
mirzamesic | 1:8e854723c742 | 58 | |
mirzamesic | 1:8e854723c742 | 59 | |
mirzamesic | 1:8e854723c742 | 60 | |
mirzamesic | 1:8e854723c742 | 61 | int main () |
mirzamesic | 1:8e854723c742 | 62 | { |
mirzamesic | 1:8e854723c742 | 63 | |
mirzamesic | 1:8e854723c742 | 64 | |
mirzamesic | 1:8e854723c742 | 65 | eckig eck; |
mirzamesic | 1:8e854723c742 | 66 | |
mirzamesic | 1:8e854723c742 | 67 | |
mirzamesic | 1:8e854723c742 | 68 | Kreis meineForm(2.0); |
mirzamesic | 1:8e854723c742 | 69 | |
mirzamesic | 1:8e854723c742 | 70 | |
mirzamesic | 1:8e854723c742 | 71 | float um = meineForm.berechneUmfang(); |
mirzamesic | 1:8e854723c742 | 72 | |
mirzamesic | 1:8e854723c742 | 73 | printf ("Der Umfang beträgt: %f\n", um); |
mirzamesic | 1:8e854723c742 | 74 | |
mirzamesic | 1:8e854723c742 | 75 | eck=meineForm.eckingauslesen(); |
mirzamesic | 1:8e854723c742 | 76 | |
mirzamesic | 1:8e854723c742 | 77 | if(eck==0) |
mirzamesic | 1:8e854723c742 | 78 | printf ("Es ist eckig\n"); |
mirzamesic | 1:8e854723c742 | 79 | else if(eck==1) |
mirzamesic | 1:8e854723c742 | 80 | printf("Es ist nicht eckig\n"); |
mirzamesic | 1:8e854723c742 | 81 | |
mirzamesic | 1:8e854723c742 | 82 | return 0; |
mirzamesic | 1:8e854723c742 | 83 | } |
mirzamesic | 1:8e854723c742 | 84 | |
mirzamesic | 1:8e854723c742 | 85 | |
mirzamesic | 1:8e854723c742 | 86 | |
mirzamesic | 1:8e854723c742 | 87 | |
mirzamesic | 1:8e854723c742 | 88 | |
mirzamesic | 1:8e854723c742 | 89 |