Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <valjak.h>
- using namespace std;
- int main()
- {
- valjak v1, v2 ;
- float x,y;
- cout << "Konstrukcija prvog valjka pomocu metode definisiValjak" << endl;
- cout << "Unesite podatke" << endl;
- cout << "Unesite poluprecnik baze ";
- cin >>x;
- cout << "Unesite visinu ";
- cin >>y;
- v1.definisiValjak(x,y);
- cout <<"Povrsina valjka je "<< v1.povrsina()<<endl;
- cout <<"Zapremina valjka je " << v1.zapremina()<<endl;
- cout << "\n\nKonstrukcija drugog valjka pomocu metoda definisiBazu i definisiOmotac" << endl;
- cout << "Unesite podatke" << endl;
- cout << "Unesite poluprecnik baze ";
- cin >>x;
- cout << "Unesite visinu ";
- cin >>y;
- // v2.definisiBazu(x);
- v2.definisiOmotac(y);
- cout <<"Povrsina valjka je "<< v2.povrsina()<<endl;
- cout <<"Zapremina valjka je " << v2.zapremina()<<endl;
- return 0;
- }
- ===========valjak.h===========
- #ifndef VALJAK_H
- #define VALJAK_H
- #include <krug.h>
- #include <pravougaonik.h>
- class valjak
- {
- public:
- valjak();
- ~valjak();
- void definisiValjak(float r, float h);
- float povrsina();
- float zapremina();
- void definisiBazu(double r);
- void definisiOmotac(double h);
- protected:
- private:
- krug baza;
- pravougaonik omotac;
- };
- #endif // VALJAK_H
- ==========pravougaonik.cpp==============
- #include "pravougaonik.h"
- pravougaonik::pravougaonik()
- {
- //ctor
- }
- pravougaonik::~pravougaonik()
- {
- //dtor
- }
- ========pravougaonik.h==============
- #ifndef PRAVOUGAONIK_H
- #define PRAVOUGAONIK_H
- class pravougaonik
- {
- public:
- pravougaonik();
- ~pravougaonik();
- float Geta() { return a; }
- void Seta(float val) { a = val; }
- float Getb() { return b; }
- void Setb(float val) { b = val; }
- float obim(){return 2*a+2*b;}
- float povrsina(){return a*b;}
- protected:
- private:
- float a;
- float b;
- };
- #endif // PRAVOUGAONIK_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement