Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include <QCoreApplication>
  2. #include <iostream>
  3. #include <math.h>
  4. using namespace std;
  5.  
  6. class Punkt{
  7.  
  8.     //atrybuty
  9. protected:
  10.     string nazwa;
  11.     float x;
  12.     float y;
  13.  
  14.     //metody
  15. public:
  16.  
  17.     void wczytaj()
  18.     {
  19.         cout << "\nPodaj nazwe punktu:"; cin >> nazwa;
  20.         cout << "\nPodaj wsp. x:"; cin >> x;
  21.         cout << "\nPodaj wsp. y:"; cin >> y;
  22.     }
  23.  
  24.     void wyswietl()
  25.     {
  26.         cout << "\nNazwa:" << nazwa;
  27.         cout << "\nWsp x:" << x;
  28.         cout << "\nWsp y:" << y;
  29.     }
  30.  
  31.     Punkt(string n="Domyslny pkt", float xx=0, float yy=0){
  32.      nazwa=n;
  33.      x=xx;
  34.      y=yy;
  35.     }
  36. };
  37.  
  38. class Kolo:public Punkt{
  39.     //atrybuty
  40.     protected:
  41.         float promien;
  42.     //metody
  43.     public:
  44.  
  45.         void wyswietl(){
  46.  
  47.             Punkt::wyswietl();
  48.             cout << "\nPromien:" << promien;
  49.             cout << "\nPole:" << M_PI*promien*promien;
  50.         }
  51.  
  52.   Kolo(string n="Domyslne kolo", float xx=0, float yy=0, float pr=2){
  53.     nazwa=n;
  54.     x=xx;
  55.     y=yy;
  56.     promien=pr;
  57.     }
  58.  
  59. };
  60.  
  61. class Kula:public Kolo{
  62.  
  63.     //atrybuty
  64.     protected:
  65.         string nazwa;
  66.     //metody
  67.     public:
  68.         void wyswietl(){
  69.  
  70.             Kolo::wyswietl();
  71.             cout << "\nObjetosc:" << 4.3*M_PI*promien*promien*promien;
  72.         }
  73.  
  74.         Kula(string nk="Domyslna kula", float xx=3, float yy=3, float pr=3){
  75.             nazwa=nk;
  76.             x=xx;
  77.             y=yy;
  78.             promien=pr;
  79.         }
  80.  
  81. };
  82.  
  83. int main(int argc, char *argv[])
  84. {
  85.     QCoreApplication a(argc, argv);
  86.  
  87.     //Punkt p1;
  88.     //p1.wczytaj();
  89.     //p1.wyswietl();
  90.  
  91.     //Kolo k1;
  92.     //k1.wyswietl();
  93.     Kula ku1;
  94.     ku1.wyswietl();
  95.  
  96.     return a.exec();
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement