Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QCoreApplication>
- #include <iostream>
- #include <math.h>
- using namespace std;
- class Punkt{
- //atrybuty
- protected:
- string nazwa;
- float x;
- float y;
- //metody
- public:
- void wczytaj()
- {
- cout << "\nPodaj nazwe punktu:"; cin >> nazwa;
- cout << "\nPodaj wsp. x:"; cin >> x;
- cout << "\nPodaj wsp. y:"; cin >> y;
- }
- void wyswietl()
- {
- cout << "\nNazwa:" << nazwa;
- cout << "\nWsp x:" << x;
- cout << "\nWsp y:" << y;
- }
- Punkt(string n="Domyslny pkt", float xx=0, float yy=0){
- nazwa=n;
- x=xx;
- y=yy;
- }
- };
- class Kolo:public Punkt{
- //atrybuty
- protected:
- float promien;
- //metody
- public:
- void wyswietl(){
- Punkt::wyswietl();
- cout << "\nPromien:" << promien;
- cout << "\nPole:" << M_PI*promien*promien;
- }
- Kolo(string n="Domyslne kolo", float xx=0, float yy=0, float pr=2){
- nazwa=n;
- x=xx;
- y=yy;
- promien=pr;
- }
- };
- class Kula:public Kolo{
- //atrybuty
- protected:
- string nazwa;
- //metody
- public:
- void wyswietl(){
- Kolo::wyswietl();
- cout << "\nObjetosc:" << 4.3*M_PI*promien*promien*promien;
- }
- Kula(string nk="Domyslna kula", float xx=3, float yy=3, float pr=3){
- nazwa=nk;
- x=xx;
- y=yy;
- promien=pr;
- }
- };
- int main(int argc, char *argv[])
- {
- QCoreApplication a(argc, argv);
- //Punkt p1;
- //p1.wczytaj();
- //p1.wyswietl();
- //Kolo k1;
- //k1.wyswietl();
- Kula ku1;
- ku1.wyswietl();
- return a.exec();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement